@@ -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
@@ -476,6 +482,12 @@ class GenericSignatureBuilder {
476
482
ArrayRef<GenericTypeParamType *> genericParams,
477
483
PotentialArchetype *pa);
478
484
485
+ // / Check same-type constraints within the equivalence class of the
486
+ // / given potential archetype.
487
+ void checkSameTypeConstraints (
488
+ ArrayRef<GenericTypeParamType *> genericParams,
489
+ PotentialArchetype *pa);
490
+
479
491
public:
480
492
// / \brief Resolve the given type to the potential archetype it names.
481
493
// /
@@ -1025,11 +1037,6 @@ class GenericSignatureBuilder::PotentialArchetype {
1025
1037
mutable llvm::PointerUnion<PotentialArchetype *, EquivalenceClass *>
1026
1038
representativeOrEquivClass;
1027
1039
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
1040
// / \brief The layout constraint of this archetype, if specified.
1034
1041
LayoutConstraint Layout;
1035
1042
@@ -1301,12 +1308,15 @@ class GenericSignatureBuilder::PotentialArchetype {
1301
1308
const RequirementSource *source);
1302
1309
1303
1310
// / 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 ());
1311
+ ArrayRef<Constraint<PotentialArchetype *>> getSameTypeConstraints () const {
1312
+ if (auto equivClass = getEquivalenceClassIfPresent ()) {
1313
+ auto known = equivClass->sameTypeConstraints .find (
1314
+ const_cast <PotentialArchetype *>(this ));
1315
+ if (known == equivClass->sameTypeConstraints .end ()) return { };
1316
+ return known->second ;
1317
+ }
1318
+
1319
+ return { };
1310
1320
}
1311
1321
1312
1322
// / \brief Retrieve (or create) a nested type with the given name.
0 commit comments