1
- // RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s
2
- // RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
1
+ // RUN: %target-swift-frontend -typecheck -verify %s -debug-generic-signatures 2>&1 | %FileCheck %s
2
+ // RUN: %target-swift-frontend -typecheck -verify %s -debug-generic-signatures -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
3
3
4
4
protocol P {
5
5
associatedtype T
@@ -15,49 +15,60 @@ protocol Q {
15
15
protocol R { }
16
16
17
17
// CHECK-LABEL: abstract_type_witnesses_in_protocols.(file).Q1@
18
- // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<Self.[Q]A.[P]T >, Self.[Q1]B : P, Self.[Q]A.[P]T == Self.[Q1]B.[P]T>
18
+ // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<<<error type>> >, Self.[Q1]B : P, Self.[Q]A.[P]T == Self.[Q1]B.[P]T>
19
19
20
20
// GSB: Non-canonical requirement
21
+ // expected-error@+1 {{same-type constraint 'Self.A' == 'G<Self.A.T>' is recursive}}
21
22
protocol Q1 : Q {
22
23
associatedtype B : P where A == G < B . T >
23
24
}
24
25
26
+ // This used to crash
27
+ func useQ1< T : Q1 > ( _: T ) -> T . A . T . Type {
28
+ return T . A. T. Type
29
+ }
30
+
25
31
// CHECK-LABEL: abstract_type_witnesses_in_protocols.(file).Q1a@
26
- // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<Self.[Q]A.[P]T >, Self.[Q1a]B : P, Self.[Q]A.[P]T : R, Self.[Q]A.[P]T == Self.[Q1a]B.[P]T>
32
+ // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<<<error type>> >, Self.[Q1a]B : P, Self.[Q]A.[P]T : R, Self.[Q]A.[P]T == Self.[Q1a]B.[P]T>
27
33
28
34
// GSB: Missing requirement
35
+ // expected-error@+1 {{same-type constraint 'Self.A' == 'G<Self.A.T>' is recursive}}
29
36
protocol Q1a : Q {
30
37
associatedtype B : P where A. T : R , A == G < B . T >
31
38
}
32
39
33
40
// CHECK-LABEL: abstract_type_witnesses_in_protocols.(file).Q1b@
34
- // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<Self.[Q]A.[P]T >, Self.[Q1b]B : P, Self.[Q]A.[P]T : R, Self.[Q]A.[P]T == Self.[Q1b]B.[P]T>
41
+ // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<<<error type>> >, Self.[Q1b]B : P, Self.[Q]A.[P]T : R, Self.[Q]A.[P]T == Self.[Q1b]B.[P]T>
35
42
36
43
// GSB: Non-canonical requirement
44
+ // expected-error@+1 {{same-type constraint 'Self.A' == 'G<Self.A.T>' is recursive}}
37
45
protocol Q1b : Q {
38
46
associatedtype B : P where B. T : R , A == G < B . T >
39
47
}
40
48
41
49
// CHECK-LABEL: abstract_type_witnesses_in_protocols.(file).Q2@
42
- // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<Self.[Q]A.[P]T >, Self.[Q2]B : P, Self.[Q]A.[P]T == Self.[Q2]B.[P]T>
50
+ // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<<<error type>> >, Self.[Q2]B : P, Self.[Q]A.[P]T == Self.[Q2]B.[P]T>
43
51
44
52
// GSB: Missing requirement
53
+ // expected-error@+1 {{same-type constraint 'Self.A' == 'G<Self.A.T>' is recursive}}
45
54
protocol Q2 : Q {
46
55
associatedtype B : P where A. T == B . T , A == G < B . T >
47
56
}
48
57
49
58
// CHECK-LABEL: abstract_type_witnesses_in_protocols.(file).Q3@
50
- // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<Self.[Q]A.[P]T >, Self.[Q3]B : P, Self.[Q]A.[P]T == Self.[Q3]B.[P]T>
59
+ // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<<<error type>> >, Self.[Q3]B : P, Self.[Q]A.[P]T == Self.[Q3]B.[P]T>
51
60
52
61
// GSB: Unsupported recursive requirement
62
+ // expected-error@+1 {{same-type constraint 'Self.A' == 'G<Self.A.T>' is recursive}}
53
63
protocol Q3 : Q {
54
64
associatedtype B : P where A == G < A . T > , A. T == B . T
55
65
}
56
66
57
67
// CHECK-LABEL: abstract_type_witnesses_in_protocols.(file).Q4@
58
- // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<Self.[Q]A.[P]T >, Self.[Q4]B : P, Self.[Q]A.[P]T == Self.[Q4]B.[P]T>
68
+ // CHECK-NEXT: Requirement signature: <Self where Self : Q, Self.[Q]A == G<<<error type>> >, Self.[Q4]B : P, Self.[Q]A.[P]T == Self.[Q4]B.[P]T>
59
69
60
70
// GSB: Unsupported recursive requirement
71
+ // expected-error@+1 {{same-type constraint 'Self.A' == 'G<Self.A.T>' is recursive}}
61
72
protocol Q4 : Q {
62
73
associatedtype B : P where A. T == B . T , A == G < A . T >
63
74
}
0 commit comments