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
23
34class C { }
45
@@ -8,18 +9,26 @@ struct S {}
89// CHECK-NEXT: Requirement signature: <Self where Self.[P1]T == C>
910protocol P1 {
1011 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}}
1114}
1215
1316// CHECK-LABEL: .P2@
1417// CHECK-NEXT: Requirement signature: <Self where Self.[P2]T == S>
1518protocol P2 {
1619 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}}
1723}
1824
1925// CHECK-LABEL: .P3@
2026// CHECK-NEXT: Requirement signature: <Self where Self.[P3]T == S>
2127protocol P3 {
2228 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}}
2332}
2433
2534protocol P4a {
@@ -30,4 +39,16 @@ protocol P4a {
3039// CHECK-NEXT: Requirement signature: <Self where Self.[P4]T : P4>
3140protocol P4 {
3241 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}}
3354}
0 commit comments