Skip to content

Commit de4c3cf

Browse files
authored
Merge pull request #38755 from slavapestov/gsb-broken-canonical-type-tests
Add some test cases where the GSB computes incorrect canonical types
2 parents feb7d76 + f88138a commit de4c3cf

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-emit-silgen %s -requirement-machine=on | %FileCheck %s
2+
3+
// The GSB computes an incorrect canonical type here, which caused a SILGen assert.
4+
5+
protocol P1 {
6+
associatedtype A
7+
}
8+
9+
protocol P2 {
10+
associatedtype A
11+
}
12+
13+
extension P1 where Self: P2 {
14+
func foo<T>(_: A, _: T) { }
15+
}
16+
17+
// CHECK-LABEL: sil hidden [ossa] @$s24gsb_canonical_type_bug_12P1PA2A2P2RzrlE3fooyy1AACQz_qd__tlF : $@convention(method) <Self where Self : P1, Self : P2><T> (@in_guaranteed Self.A, @in_guaranteed T, @in_guaranteed Self) -> ()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-swift-emit-silgen %s -requirement-machine=on | %FileCheck %s
2+
// RUN: %target-swift-emit-silgen %s -requirement-machine=off | %FileCheck %s --check-prefix=CHECK-GSB
3+
// RUN: not --crash %target-swift-emit-silgen %s -requirement-machine=verify
4+
5+
protocol P1 {
6+
associatedtype A
7+
}
8+
9+
protocol P2 {
10+
associatedtype A
11+
}
12+
13+
protocol P3 {
14+
associatedtype B
15+
associatedtype C : P3 where C.C == C, C.B == B
16+
}
17+
18+
extension P2 {
19+
func foo<T : P1 & P3>(_: T, _: T.A) where T.B == T, T.A == A {
20+
_ = A.self
21+
_ = T.A.self
22+
}
23+
}
24+
25+
// CHECK-LABEL: sil hidden [ossa] @$s24gsb_canonical_type_bug_22P2PAAE3fooyyqd___1AQztAA2P1Rd__AA2P3Rd__1BAaHPQyd__Rsd__AeaGPQyd__AFRSlF : $@convention(method) <Self where Self : P2><T where T : P1, T : P3, T == T.B, Self.A == T.A> (@in_guaranteed T, @in_guaranteed Self.A, @in_guaranteed Self) -> ()
26+
// CHECK-GSB-LABEL: sil hidden [ossa] @$s24gsb_canonical_type_bug_22P2PAAE3fooyyqd___1AAA2P1PQyd__tAaFRd__AA2P3Rd__1BAaIPQyd__Rsd__AhERtzlF : $@convention(method) <Self where Self : P2><T where T : P1, T : P3, T == T.B, Self.A == T.A> (@in_guaranteed T, @in_guaranteed T.A, @in_guaranteed Self) -> ()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-swift-emit-silgen %s -requirement-machine=on | %FileCheck %s
2+
3+
// The GSB computes an incorrect canonical type for bar() which causes
4+
// SILGen to assert.
5+
6+
public protocol P1 {
7+
associatedtype A
8+
}
9+
10+
public protocol P2 {
11+
associatedtype A
12+
}
13+
14+
public protocol P3 : P1, P2 {
15+
typealias B = A
16+
}
17+
18+
public protocol P4 {}
19+
20+
func bar<T : P3 & P4, X>(x: T, y: T.B, _: X) {}
21+
22+
// CHECK-LABEL: sil hidden [ossa] @$s24gsb_canonical_type_bug_33bar1x1y_yx_1AAA2P1PQzq_tAA2P3RzAA2P4Rzr0_lF : $@convention(thin) <T, X where T : P3, T : P4> (@in_guaranteed T, @in_guaranteed T.A, @in_guaranteed X) -> ()

0 commit comments

Comments
 (0)