@@ -137,6 +137,22 @@ class GenericSignatureBuilder {
137
137
// / The members of the equivalence class.
138
138
TinyPtrVector<PotentialArchetype *> members;
139
139
140
+ // / Describes a component within the graph of same-type constraints within
141
+ // / the equivalence class that is held together by derived constraints.
142
+ struct DerivedSameTypeComponent {
143
+ // / The potential archetype that acts as the anchor for this component.
144
+ PotentialArchetype *anchor;
145
+
146
+ // / The (best) requirement source within the component that makes the
147
+ // / potential archetypes in this component equivalent to the concrete
148
+ // / type.
149
+ const RequirementSource *concreteTypeSource;
150
+ };
151
+
152
+ // / The set of connected components within this equivalence class, using
153
+ // / only the derived same-type constraints in the graph.
154
+ std::vector<DerivedSameTypeComponent> derivedSameTypeComponents;
155
+
140
156
// / Construct a new equivalence class containing only the given
141
157
// / potential archetype (which represents itself).
142
158
EquivalenceClass (PotentialArchetype *representative);
@@ -462,6 +478,32 @@ class GenericSignatureBuilder {
462
478
Diag<Type, T> redundancyDiag,
463
479
Diag<bool, Type, T> otherNoteDiag);
464
480
481
+ // / Check a list of constraints, removing self-derived constraints
482
+ // / and diagnosing redundant constraints.
483
+ // /
484
+ // / \param isSuitableRepresentative Determines whether the given constraint
485
+ // / is a suitable representative.
486
+ // /
487
+ // / \param checkConstraint Checks the given constraint against the
488
+ // / canonical constraint to determine which diagnostics (if any) should be
489
+ // / emitted.
490
+ // /
491
+ // / \returns the representative constraint.
492
+ template <typename T, typename DiagT>
493
+ Constraint<T> checkConstraintList (
494
+ ArrayRef<GenericTypeParamType *> genericParams,
495
+ std::vector<Constraint<T>> &constraints,
496
+ llvm::function_ref<bool (const Constraint<T> &)>
497
+ isSuitableRepresentative,
498
+ llvm::function_ref<ConstraintRelation(const T&)>
499
+ checkConstraint,
500
+ Optional<Diag<unsigned, Type, DiagT, DiagT>>
501
+ conflictingDiag,
502
+ Diag<Type, DiagT> redundancyDiag,
503
+ Diag<bool, Type, DiagT> otherNoteDiag,
504
+ llvm::function_ref<DiagT(const T&)> diagValue,
505
+ bool removeSelfDerived);
506
+
465
507
// / Check the concrete type constraints within the equivalence
466
508
// / class of the given potential archetype.
467
509
void checkConcreteTypeConstraints (
0 commit comments