Skip to content

Commit 39ab69a

Browse files
committed
RequirementMachine: Relax assertion in verifyRewriteSystem()
This invariant is no longer required with the new minimal conformances algorithm. Fixes rdar://problem/94746399.
1 parent f20cb3c commit 39ab69a

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

lib/AST/RequirementMachine/RewriteSystem.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ void RewriteSystem::verifyRewriteRules(ValidityPolicy policy) const {
556556
ASSERT_RULE(symbol.getKind() != Symbol::Kind::GenericParam);
557557
}
558558

559-
if (index != 0 && index != lhs.size() - 1) {
559+
if (index != 0 && index != lhs.size() - 1 &&
560+
!rule.isLHSSimplified()) {
560561
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Protocol);
561562
}
562563
}
@@ -585,13 +586,18 @@ void RewriteSystem::verifyRewriteRules(ValidityPolicy policy) const {
585586
}
586587

587588
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Layout);
588-
ASSERT_RULE(!symbol.hasSubstitutions());
589+
590+
if (!rule.isRHSSimplified() &&
591+
index != rhs.size() - 1) {
592+
ASSERT_RULE(!symbol.hasSubstitutions());
593+
}
589594

590595
if (index != 0) {
591596
ASSERT_RULE(symbol.getKind() != Symbol::Kind::GenericParam);
592597
}
593598

594-
if (index != 0 && !rule.isRHSSimplified()) {
599+
if (!rule.isRHSSimplified() &&
600+
index != 0) {
595601
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Protocol);
596602
}
597603
}

test/Generics/rdar9474639.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s
2+
3+
// CHECK-LABEL: .P1@
4+
// CHECK-NEXT: Requirement signature: <Self where Self == Self.[P1]T.[P2]T, Self.[P1]T : P2>
5+
protocol P1 {
6+
associatedtype T: P2 where T.T == Self
7+
}
8+
9+
// CHECK-LABEL: .P2@
10+
// CHECK-NEXT: Requirement signature: <Self where Self == Self.[P2]T.[P1]T, Self.[P2]T : P1>
11+
protocol P2 {
12+
associatedtype T: P1 where T.T == Self
13+
}
14+
15+
class SomeClass {}
16+
17+
// CHECK-LABEL: .P3@
18+
// CHECK-NEXT: Requirement signature: <Self where Self : P2, Self.[P2]T : SomeClass>
19+
protocol P3: P2 where T: SomeClass {}
20+
21+
protocol P4 {
22+
associatedtype T
23+
}
24+
25+
// CHECK-LABEL: .foo@
26+
// CHECK-NEXT: Generic signature: <T where T : P4, T.[P4]T : P1, T.[P4]T.[P1]T : P3>
27+
func foo<T: P4>(_: T) where T.T: P1, T.T.T: P3 {}

0 commit comments

Comments
 (0)