@@ -215,6 +215,15 @@ class GenericSignatureBuilder {
215
215
// / a superclass requirement.
216
216
bool isConformanceSatisfiedBySuperclass (ProtocolDecl *proto) const ;
217
217
218
+ // / Lookup a nested type with the given name within this equivalence
219
+ // / class.
220
+ // /
221
+ // / \param otherConcreteTypes If non-null, will be filled in the all of the
222
+ // / concrete types we found (other than the result) with the same name.
223
+ TypeDecl *lookupNestedType (
224
+ Identifier name,
225
+ SmallVectorImpl<TypeDecl *> *otherConcreteTypes = nullptr );
226
+
218
227
// / Dump a debugging representation of this equivalence class.
219
228
void dump (llvm::raw_ostream &out) const ;
220
229
@@ -232,6 +241,17 @@ class GenericSignatureBuilder {
232
241
// / anchor was cached.
233
242
unsigned numMembers;
234
243
} archetypeAnchorCache;
244
+
245
+ // / Describes a cached nested type.
246
+ struct CachedNestedType {
247
+ unsigned numConformancesPresent;
248
+ CanType superclassPresent;
249
+ llvm::TinyPtrVector<TypeDecl *> types;
250
+ };
251
+
252
+ // / Cached nested-type information, which contains the best declaration
253
+ // / for a given name.
254
+ llvm::SmallDenseMap<Identifier, CachedNestedType> nestedTypeNameCache;
235
255
};
236
256
237
257
friend class RequirementSource ;
@@ -522,9 +542,6 @@ class GenericSignatureBuilder {
522
542
// / \brief Add all of a generic signature's parameters and requirements.
523
543
void addGenericSignature (GenericSignature *sig);
524
544
525
- // / \brief Build the generic signature.
526
- GenericSignature *getGenericSignature ();
527
-
528
545
// / Infer requirements from the given type, recursively.
529
546
// /
530
547
// / This routine infers requirements from a type that occurs within the
@@ -558,11 +575,13 @@ class GenericSignatureBuilder {
558
575
// / \brief Finalize the set of requirements and compute the generic
559
576
// / signature.
560
577
// /
561
- // / After this point, one cannot introduce new requirements.
578
+ // / After this point, one cannot introduce new requirements, and the
579
+ // / generic signature builder no longer has valid state.
562
580
GenericSignature *computeGenericSignature (
563
581
SourceLoc loc,
564
- bool allowConcreteGenericParams = false );
582
+ bool allowConcreteGenericParams = false ) && ;
565
583
584
+ private:
566
585
// / Finalize the set of requirements, performing any remaining checking
567
586
// / required before generating archetypes.
568
587
// /
@@ -572,6 +591,7 @@ class GenericSignatureBuilder {
572
591
ArrayRef<GenericTypeParamType *> genericParams,
573
592
bool allowConcreteGenericParams=false );
574
593
594
+ public:
575
595
// / Process any delayed requirements that can be handled now.
576
596
void processDelayedRequirements ();
577
597
@@ -1490,6 +1510,12 @@ class GenericSignatureBuilder::PotentialArchetype {
1490
1510
return parentOrBuilder.dyn_cast <PotentialArchetype *>();
1491
1511
}
1492
1512
1513
+ // / Retrieve the type declaration to which this nested type was resolved.
1514
+ TypeDecl *getResolvedType () const {
1515
+ assert (getParent () && " Not an associated type" );
1516
+ return identifier.assocTypeOrConcrete ;
1517
+ }
1518
+
1493
1519
// / Retrieve the associated type to which this potential archetype
1494
1520
// / has been resolved.
1495
1521
AssociatedTypeDecl *getResolvedAssociatedType () const {
@@ -1632,13 +1658,8 @@ class GenericSignatureBuilder::PotentialArchetype {
1632
1658
ArchetypeResolutionKind kind,
1633
1659
GenericSignatureBuilder &builder);
1634
1660
1635
- // / \brief Retrieve (or create) a nested type with a known associated type.
1636
- PotentialArchetype *getNestedType (AssociatedTypeDecl *assocType,
1637
- GenericSignatureBuilder &builder);
1638
-
1639
- // / \brief Retrieve (or create) a nested type with a known concrete type
1640
- // / declaration.
1641
- PotentialArchetype *getNestedType (TypeDecl *concreteDecl,
1661
+ // / \brief Retrieve (or create) a nested type with a known type.
1662
+ PotentialArchetype *getNestedType (TypeDecl *type,
1642
1663
GenericSignatureBuilder &builder);
1643
1664
1644
1665
// / \brief Retrieve (or create) a nested type that is the current best
@@ -1658,8 +1679,8 @@ class GenericSignatureBuilder::PotentialArchetype {
1658
1679
// / type or typealias of the given protocol, unless the \c kind implies that
1659
1680
// / a potential archetype should not be created if it's missing.
1660
1681
PotentialArchetype *updateNestedTypeForConformance (
1661
- PointerUnion<AssociatedTypeDecl *, TypeDecl *> type,
1662
- ArchetypeResolutionKind kind);
1682
+ TypeDecl *type,
1683
+ ArchetypeResolutionKind kind);
1663
1684
1664
1685
// / Update the named nested type when we know this type conforms to the given
1665
1686
// / protocol.
0 commit comments