Skip to content

Commit fe0b00b

Browse files
authored
Merge pull request #59935 from slavapestov/rqm-relax-assert-rdar9474639
RequirementMachine: Relax assertions in verifyRewriteSystem() [5.7]
2 parents b0b5f0c + d334fe9 commit fe0b00b

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

lib/AST/RequirementMachine/RewriteSystem.cpp

Lines changed: 4 additions & 2 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 (!rule.isLHSSimplified() &&
560+
index != 0 && index != lhs.size() - 1) {
560561
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Protocol);
561562
}
562563
}
@@ -591,7 +592,8 @@ void RewriteSystem::verifyRewriteRules(ValidityPolicy policy) const {
591592
ASSERT_RULE(symbol.getKind() != Symbol::Kind::GenericParam);
592593
}
593594

594-
if (index != 0 && !rule.isRHSSimplified()) {
595+
if (!rule.isRHSSimplified() &&
596+
index != 0) {
595597
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Protocol);
596598
}
597599
}

test/Generics/rdar94746399.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)