1
- // RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
1
+ // RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=verify
2
+ // RUN: not %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=verify -requirement-machine-inferred-signatures=verify 2>&1 | %FileCheck %s
2
3
3
4
class C { }
4
5
@@ -8,18 +9,26 @@ struct S {}
8
9
// CHECK-NEXT: Requirement signature: <Self where Self.[P1]T == C>
9
10
protocol P1 {
10
11
associatedtype T where T : C , T == C
12
+ // expected-warning@-1 {{redundant superclass constraint 'Self.T' : 'C'}}
13
+ // expected-note@-2 {{superclass constraint 'Self.T' : 'C' implied here}}
11
14
}
12
15
13
16
// CHECK-LABEL: .P2@
14
17
// CHECK-NEXT: Requirement signature: <Self where Self.[P2]T == S>
15
18
protocol P2 {
16
19
associatedtype T where T : C , T == S
20
+ // expected-error@-1 {{'Self.T' requires that 'S' inherit from 'C'}}
21
+ // expected-note@-2 {{superclass constraint 'Self.T' : 'C' implied here}}
22
+ // expected-note@-3 {{same-type constraint 'Self.T' == 'S' implied here}}
17
23
}
18
24
19
25
// CHECK-LABEL: .P3@
20
26
// CHECK-NEXT: Requirement signature: <Self where Self.[P3]T == S>
21
27
protocol P3 {
22
28
associatedtype T where T == S , T : C
29
+ // expected-error@-1 {{'Self.T' requires that 'S' inherit from 'C'}}
30
+ // expected-note@-2 {{same-type constraint 'Self.T' == 'S' implied here}}
31
+ // expected-note@-3 {{superclass constraint 'Self.T' : 'C' implied here}}
23
32
}
24
33
25
34
protocol P4a {
@@ -30,4 +39,16 @@ protocol P4a {
30
39
// CHECK-NEXT: Requirement signature: <Self where Self.[P4]T : P4>
31
40
protocol P4 {
32
41
associatedtype T : P4 where T. T == S
42
+ // expected-error@-1 2{{same-type constraint type 'S' does not conform to required protocol 'P4'}}
43
+ }
44
+
45
+ class D { }
46
+
47
+ // CHECK-LABEL: .P5@
48
+ // CHECK-NEXT: Requirement signature: <Self where Self.[P5]T == D>
49
+ protocol P5 {
50
+ associatedtype T where T : C , T == D
51
+ // expected-error@-1 {{'Self.T' requires that 'D' inherit from 'C'}}
52
+ // expected-note@-2 {{superclass constraint 'Self.T' : 'C' implied here}}
53
+ // expected-note@-3 {{same-type constraint 'Self.T' == 'D' implied here}}
33
54
}
0 commit comments