Skip to content

Commit 2f7018b

Browse files
committed
[RequirementMachine] Don't suppress redundancy diagnostics when the
non-explicit, non-redundant replacement rule is not in the rewrite system's minimization domain.
1 parent 3976849 commit 2f7018b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/AST/RequirementMachine/RewriteSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ RewriteSystem::getRedundantRequirements() {
741741
for (unsigned ruleID : indices(getRules())) {
742742
auto &rule = getRules()[ruleID];
743743

744-
if (!rule.isExplicit() && !rule.isPermanent() && !rule.isRedundant())
744+
if (!rule.isExplicit() && !rule.isPermanent() && !rule.isRedundant() &&
745+
isInMinimizationDomain(rule.getLHS().getRootProtocol()))
745746
impliedRequirements.insert(ruleID);
746747

747748
if (!rule.isExplicit())

test/Generics/rdar83308672.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ protocol G1 {
4040
// CHECK: rdar83308672.(file).G2@
4141
// CHECK-NEXT: Requirement signature: <Self where Self.[G2]T : A, Self.[G2]T.[A]X == Self.[G2]T.[A]Y>
4242
protocol G2 {
43-
associatedtype T : A where T : B, T.X == T.Y
43+
associatedtype T : A where T : B, T.X == T.Y // expected-warning {{redundant conformance constraint 'Self.T' : 'B'}}
4444
}
4545

4646
// CHECK: rdar83308672.(file).G3@
4747
// CHECK-NEXT: Requirement signature: <Self where Self.[G3]T : A, Self.[G3]T.[A]X == Self.[G3]T.[A]Y>
4848
protocol G3 {
49-
associatedtype T : A where T.X == T.Y, T : B
49+
associatedtype T : A where T.X == T.Y, T : B // expected-warning {{redundant conformance constraint 'Self.T' : 'B'}}
5050
}
5151

5252
// CHECK: rdar83308672.(file).G4@

test/Generics/requirement_machine_diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protocol P7 : P6 {
152152
associatedtype AssocP7: P6
153153
}
154154

155-
// FIXME: diagnose redundant requirement 'AssocP6.Element : P6'
155+
// expected-warning@+1{{redundant conformance constraint 'Self.AssocP6.Element' : 'P6'}}
156156
extension P7 where AssocP6.Element : P6,
157157
AssocP7.AssocP6.Element : P6,
158158
AssocP6.Element == AssocP7.AssocP6.Element {

0 commit comments

Comments
 (0)