@@ -7113,8 +7113,45 @@ void GenericSignatureBuilder::diagnoseRedundantRequirements() const {
7113
7113
break ;
7114
7114
}
7115
7115
7116
+ case RequirementKind::Layout: {
7117
+ auto layout = req.getRHS ().get <LayoutConstraint>();
7118
+
7119
+ auto conflict = Impl->ConflictingRequirements .find (req);
7120
+ if (conflict != Impl->ConflictingRequirements .end ()) {
7121
+ Impl->HadAnyError = true ;
7122
+
7123
+ auto otherLayout = conflict->second .get <LayoutConstraint>();
7124
+ Context.Diags .diagnose (loc, diag::conflicting_layout_constraints,
7125
+ subjectType, layout, otherLayout);
7126
+
7127
+ for (auto otherReq : found->second ) {
7128
+ auto *otherSource = otherReq.getSource ();
7129
+ auto otherLoc = otherSource->getLoc ();
7130
+ if (otherLoc.isInvalid ())
7131
+ continue ;
7132
+
7133
+ Context.Diags .diagnose (otherLoc, diag::conflicting_layout_constraint,
7134
+ subjectType, otherLayout);
7135
+ }
7136
+ } else {
7137
+ Context.Diags .diagnose (loc, diag::redundant_layout_constraint,
7138
+ subjectType, layout);
7139
+
7140
+ for (auto otherReq : found->second ) {
7141
+ auto *otherSource = otherReq.getSource ();
7142
+ auto otherLoc = otherSource->getLoc ();
7143
+ if (otherLoc.isInvalid ())
7144
+ continue ;
7145
+
7146
+ Context.Diags .diagnose (otherLoc, diag::previous_layout_constraint,
7147
+ subjectType, layout);
7148
+ }
7149
+ }
7150
+
7151
+ break ;
7152
+ }
7153
+
7116
7154
case RequirementKind::Superclass:
7117
- case RequirementKind::Layout:
7118
7155
case RequirementKind::SameType:
7119
7156
// TODO
7120
7157
break ;
@@ -8023,24 +8060,7 @@ void GenericSignatureBuilder::checkLayoutConstraints(
8023
8060
EquivalenceClass *equivClass) {
8024
8061
if (!equivClass->layout ) return ;
8025
8062
8026
- checkConstraintList<LayoutConstraint>(
8027
- genericParams, equivClass->layoutConstraints , RequirementKind::Layout,
8028
- [&](const Constraint<LayoutConstraint> &constraint) {
8029
- return constraint.value == equivClass->layout ;
8030
- },
8031
- [&](const Constraint<LayoutConstraint> &constraint) {
8032
- auto layout = constraint.value ;
8033
-
8034
- // If the layout constraints are mergable, i.e. compatible,
8035
- // it is a redundancy.
8036
- if (layout.merge (equivClass->layout )->isKnownLayout ())
8037
- return ConstraintRelation::Redundant;
8038
-
8039
- return ConstraintRelation::Conflicting;
8040
- },
8041
- diag::conflicting_layout_constraints,
8042
- diag::redundant_layout_constraint,
8043
- diag::previous_layout_constraint);
8063
+ removeSelfDerived (*this , equivClass->layoutConstraints , /* proto=*/ nullptr );
8044
8064
}
8045
8065
8046
8066
bool GenericSignatureBuilder::isRedundantExplicitRequirement (
0 commit comments