@@ -104,6 +104,12 @@ class GenericSignatureBuilder {
104
104
llvm::MapVector<ProtocolDecl *, std::vector<Constraint<ProtocolDecl *>>>
105
105
conformsTo;
106
106
107
+ // / Same-type constraints between each potential archetype and any other
108
+ // / archetype in its equivalence class.
109
+ llvm::MapVector<PotentialArchetype *,
110
+ std::vector<Constraint<PotentialArchetype *>>>
111
+ sameTypeConstraints;
112
+
107
113
// / Concrete type to which this equivalence class is equal.
108
114
// /
109
115
// / This is the semantic concrete type; the constraints as written
@@ -163,14 +169,6 @@ class GenericSignatureBuilder {
163
169
GenericSignatureBuilder (const GenericSignatureBuilder &) = delete ;
164
170
GenericSignatureBuilder &operator =(const GenericSignatureBuilder &) = delete ;
165
171
166
- // / Update an existing constraint source reference when another constraint
167
- // / source was found to produce the same constraint. Only the better
168
- // / constraint source will be kept.
169
- // /
170
- // / \returns true if the new constraint source was better, false otherwise.
171
- bool updateRequirementSource (const RequirementSource *&existingSource,
172
- const RequirementSource *newSource);
173
-
174
172
// / Retrieve the constraint source conformance for the superclass constraint
175
173
// / of the given potential archetype (if present) to the given protocol.
176
174
// /
@@ -458,15 +456,15 @@ class GenericSignatureBuilder {
458
456
Diag<Type, T> redundancyDiag,
459
457
Diag<bool, Type, T> otherNoteDiag);
460
458
461
- // / Check for redundant concrete type constraints within the equivalence
459
+ // / Check the concrete type constraints within the equivalence
462
460
// / class of the given potential archetype.
463
- void checkRedundantConcreteTypeConstraints (
461
+ void checkConcreteTypeConstraints (
464
462
ArrayRef<GenericTypeParamType *> genericParams,
465
463
PotentialArchetype *pa);
466
464
467
- // / Check for redundant superclass constraints within the equivalence
465
+ // / Check the superclass constraints within the equivalence
468
466
// / class of the given potential archetype.
469
- void checkRedundantSuperclassConstraints (
467
+ void checkSuperclassConstraints (
470
468
ArrayRef<GenericTypeParamType *> genericParams,
471
469
PotentialArchetype *pa);
472
470
@@ -476,6 +474,12 @@ class GenericSignatureBuilder {
476
474
ArrayRef<GenericTypeParamType *> genericParams,
477
475
PotentialArchetype *pa);
478
476
477
+ // / Check same-type constraints within the equivalence class of the
478
+ // / given potential archetype.
479
+ void checkSameTypeConstraints (
480
+ ArrayRef<GenericTypeParamType *> genericParams,
481
+ PotentialArchetype *pa);
482
+
479
483
public:
480
484
// / \brief Resolve the given type to the potential archetype it names.
481
485
// /
@@ -1025,11 +1029,6 @@ class GenericSignatureBuilder::PotentialArchetype {
1025
1029
mutable llvm::PointerUnion<PotentialArchetype *, EquivalenceClass *>
1026
1030
representativeOrEquivClass;
1027
1031
1028
- // / Same-type constraints between this potential archetype and any other
1029
- // / archetype in its equivalence class.
1030
- llvm::MapVector<PotentialArchetype *, const RequirementSource *>
1031
- SameTypeConstraints;
1032
-
1033
1032
// / \brief The layout constraint of this archetype, if specified.
1034
1033
LayoutConstraint Layout;
1035
1034
@@ -1301,12 +1300,15 @@ class GenericSignatureBuilder::PotentialArchetype {
1301
1300
const RequirementSource *source);
1302
1301
1303
1302
// / Retrieve the same-type constraints.
1304
- llvm::iterator_range<
1305
- std::vector<std::pair<PotentialArchetype *, const RequirementSource *>>
1306
- ::const_iterator>
1307
- getSameTypeConstraints () const {
1308
- return llvm::make_range (SameTypeConstraints.begin (),
1309
- SameTypeConstraints.end ());
1303
+ ArrayRef<Constraint<PotentialArchetype *>> getSameTypeConstraints () const {
1304
+ if (auto equivClass = getEquivalenceClassIfPresent ()) {
1305
+ auto known = equivClass->sameTypeConstraints .find (
1306
+ const_cast <PotentialArchetype *>(this ));
1307
+ if (known == equivClass->sameTypeConstraints .end ()) return { };
1308
+ return known->second ;
1309
+ }
1310
+
1311
+ return { };
1310
1312
}
1311
1313
1312
1314
// / \brief Retrieve (or create) a nested type with the given name.
0 commit comments