@@ -377,17 +377,38 @@ class GenericSignatureBuilder {
377
377
using RequirementRHS =
378
378
llvm::PointerUnion3<Type, PotentialArchetype *, LayoutConstraint>;
379
379
380
+ // / Describes a constraint that is bounded on one side by a concrete type.
381
+ struct ConcreteConstraint {
382
+ PotentialArchetype *archetype;
383
+ Type concreteType;
384
+ const RequirementSource *source;
385
+ };
386
+
380
387
// / Describes an equivalence class of potential archetypes.
381
388
struct EquivalenceClass {
382
389
// / Concrete type to which this equivalence class is equal.
390
+ // /
391
+ // / This is the semantic concrete type; the constraints as written
392
+ // / (or implied) are stored in \c concreteTypeConstraints;
383
393
Type concreteType;
384
394
395
+ // / The same-type-to-concrete constraints written within this
396
+ // / equivalence class.
397
+ std::vector<ConcreteConstraint> concreteTypeConstraints;
398
+
385
399
// / The members of the equivalence class.
386
400
TinyPtrVector<PotentialArchetype *> members;
387
401
388
402
// / Construct a new equivalence class containing only the given
389
403
// / potential archetype (which represents itself).
390
404
EquivalenceClass (PotentialArchetype *representative);
405
+
406
+ // / Find a source of the same-type constraint that maps a potential
407
+ // / archetype in this equivalence class to a concrete type along with
408
+ // / that concrete type as written.
409
+ Optional<ConcreteConstraint>
410
+ findAnyConcreteConstraintAsWritten (
411
+ PotentialArchetype *preferredPA = nullptr ) const ;
391
412
};
392
413
393
414
friend class RequirementSource ;
@@ -602,7 +623,7 @@ class GenericSignatureBuilder {
602
623
// / where \c Dictionary requires that its key type be \c Hashable,
603
624
// / the requirement \c K : Hashable is inferred from the parameter type,
604
625
// / because the type \c Dictionary<K,V> cannot be formed without it.
605
- void inferRequirements (TypeLoc type, unsigned minDepth, unsigned maxDepth );
626
+ void inferRequirements (TypeLoc type);
606
627
607
628
// / Infer requirements from the given pattern, recursively.
608
629
// /
@@ -736,16 +757,6 @@ class GenericSignatureBuilder::PotentialArchetype {
736
757
llvm::MapVector<Identifier, llvm::TinyPtrVector<PotentialArchetype *>>
737
758
NestedTypes;
738
759
739
- // / The concrete types to which this potential archetype has been
740
- // / constrained.
741
- // /
742
- // / This vector runs parallel to ConcreteTypeSources.
743
- llvm::TinyPtrVector<Type> concreteTypes;
744
-
745
- // / The source of the concrete type requirements that were written on
746
- // / this potential archetype.
747
- llvm::TinyPtrVector<const RequirementSource *> concreteTypeSources;
748
-
749
760
// / Whether this is an unresolved nested type.
750
761
unsigned isUnresolvedNestedType : 1 ;
751
762
@@ -973,22 +984,6 @@ class GenericSignatureBuilder::PotentialArchetype {
973
984
SameTypeConstraints.end ());
974
985
}
975
986
976
- // / Retrieve the concrete types as written on this potential archetype.
977
- const llvm::TinyPtrVector<Type>& getConcreteTypesAsWritten () const {
978
- return concreteTypes;
979
- }
980
-
981
- // / Retrieve the concrete type sources as written on this potential archetype.
982
- ArrayRef<const RequirementSource *> getConcreteTypeSourcesAsWritten () const {
983
- return concreteTypeSources;
984
- }
985
-
986
- // / Find a source of the same-type constraint that maps this potential
987
- // / archetype to a concrete type somewhere in the equivalence class of this
988
- // / type along with the concrete type that was written there.
989
- Optional<std::pair<Type, const RequirementSource *>>
990
- findAnyConcreteTypeSourceAsWritten () const ;
991
-
992
987
// / \brief Retrieve (or create) a nested type with the given name.
993
988
PotentialArchetype *getNestedType (Identifier Name,
994
989
GenericSignatureBuilder &builder);
0 commit comments