Skip to content

Commit 1f527af

Browse files
authored
Merge pull request #59557 from slavapestov/rqm-relax-verify-assert-5.7
RequirementMachine: Relax assertion in verifyRewriteSystem() [5.7]
2 parents 1102e93 + 3e4e9f3 commit 1f527af

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

lib/AST/RequirementMachine/RewriteSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ void RewriteSystem::verifyRewriteRules(ValidityPolicy policy) const {
591591
ASSERT_RULE(symbol.getKind() != Symbol::Kind::GenericParam);
592592
}
593593

594-
if (index != 0) {
594+
if (index != 0 && !rule.isRHSSimplified()) {
595595
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Protocol);
596596
}
597597
}

test/Generics/rdar94854326.swift

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

test/Generics/rdar94980084.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s
2+
3+
struct G<Value> {}
4+
5+
protocol P {
6+
associatedtype T
7+
}
8+
9+
// CHECK-LABEL: ExtensionDecl line={{.*}} base=G
10+
// CHECK-NEXT: <Value where Value : P, Value.[P]T : CaseIterable, Value.[P]T.[CaseIterable]AllCases : RandomAccessCollection>
11+
extension G where Value: P, Value.T: CaseIterable, Value.T.AllCases: RandomAccessCollection {}

0 commit comments

Comments
 (0)