Skip to content

Commit 6095065

Browse files
committed
RequirementMachine: Add a performance/diagnostics test case
1 parent d90e812 commit 6095065

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

test/Generics/rdar51908331.swift

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=on -requirement-machine-abstract-signatures=on
2+
3+
// Reduced from https://github.com/plx/HDXLSIMDSupport.
4+
5+
protocol PA: PB, PC, PD {}
6+
7+
protocol PB: PE where A2 == A3, A4 == A2, A5 == A6, A1 == Self {}
8+
// expected-warning@-1 {{redundant same-type constraint 'Self.A2' == 'Self.A3'}}
9+
// expected-warning@-2 {{redundant same-type constraint 'Self.A5' == 'Self.A6'}}
10+
11+
protocol PC: PG where A5 == (A2, A2), A3 == A7.A8 {}
12+
13+
protocol PD: PG where A6 == (A3, A3), A2 == A7.A8 {}
14+
15+
protocol PE: PF where A1.A1 == Self {}
16+
17+
protocol PF: PG {
18+
associatedtype A1: PF where A1.A7 == A7, A1.A2 == A3, A1.A3 == A2, A1.A5 == A6, A1.A6 == A5
19+
// expected-warning@-1 {{redundant same-type constraint 'Self.A1.A7' == 'Self.A7'}}
20+
}
21+
22+
protocol PG: PH where A7: PI, A7: BinaryFloatingPoint {
23+
associatedtype A2: PJ where A2.A7 == A7
24+
associatedtype A3: PJ where A3.A7 == A7
25+
associatedtype A4: PJ where A4.A7 == A7
26+
associatedtype A5
27+
associatedtype A6
28+
}
29+
30+
protocol PH {
31+
associatedtype A7: SIMDScalar
32+
}
33+
34+
protocol PI {
35+
associatedtype A8 where A8.A7 == Self // expected-warning {{redundant same-type constraint 'Self.A8.A7' == 'Self'}}
36+
associatedtype A9 where A9.A7 == Self, A9.A8 == A8
37+
associatedtype A10 where A10.A7 == Self, A10.A8 == A8, A10.A9 == A9 // expected-warning {{redundant same-type constraint 'Self.A10.A7' == 'Self'}}
38+
associatedtype A11 where A11.A7 == Self, A11.A10 == A10 // expected-warning {{redundant same-type constraint 'Self.A11.A7' == 'Self'}}
39+
associatedtype A12 where A12.A7 == Self, A12.A11 == A11 // expected-warning {{redundant same-type constraint 'Self.A12.A7' == 'Self'}}
40+
associatedtype A13 where A13.A7 == Self, A13.A12 == A12 // expected-warning {{redundant same-type constraint 'Self.A13.A7' == 'Self'}}
41+
associatedtype A14: PK where A14.A7 == Self, A14.A13 == A13 // expected-warning {{redundant same-type constraint 'Self.A14.A7' == 'Self'}}
42+
}
43+
44+
protocol PJ: SIMD, PH where Scalar == A7 {}
45+
46+
protocol PK: SIMD, PH where Scalar == A7 {
47+
associatedtype A13: PL where A13.Scalar == Scalar
48+
}
49+
50+
protocol PL: SIMD, PH where Scalar == A7 {
51+
associatedtype A12: PM where A12.Scalar == Scalar
52+
}
53+
54+
protocol PM: SIMD, PH where Scalar == A7 {
55+
associatedtype A11: PN where A11.Scalar == Scalar
56+
}
57+
58+
protocol PN: SIMD, PH where Scalar == A7 {
59+
associatedtype A10: PO where A10.Scalar == Scalar
60+
}
61+
62+
protocol PO: SIMD, PH where Scalar == A7 {
63+
associatedtype A8: PQ where A8.Scalar == Scalar
64+
associatedtype A9: PP where A9.Scalar == Scalar
65+
}
66+
67+
protocol PP: SIMD, PH where Scalar == A7 {
68+
associatedtype A8: PQ where A8.Scalar == Scalar
69+
}
70+
71+
protocol PQ: SIMD, PH where Scalar == A7 {}
72+
73+
func sameType<T>(_: T, _: T) {}
74+
75+
func testPI1<T : PI>(_: T) {
76+
sameType(T.A8.A7.self, T.self)
77+
}
78+
79+
func testPI2<T : PI>(_: T) {
80+
sameType(T.A10.A7.self, T.self)
81+
}
82+
83+
func testPI3<T : PI>(_: T) {
84+
sameType(T.A11.A7.self, T.self)
85+
}
86+
87+
func testPI4<T : PI>(_: T) {
88+
sameType(T.A12.A7.self, T.self)
89+
}
90+
91+
func testPI5<T : PI>(_: T) {
92+
sameType(T.A13.A7.self, T.self)
93+
}
94+
95+
func testPI6<T : PI>(_: T) {
96+
sameType(T.A14.A7.self, T.self)
97+
}
98+
99+
func testPF1<T : PF>(_: T) {
100+
sameType(T.A1.A7.self, T.A7.self)
101+
}
102+
103+
func testPB1<T : PB>(_: T) {
104+
sameType(T.A2.self, T.A3.self)
105+
}
106+
107+
func testPB2<T : PB>(_: T) {
108+
sameType(T.A5.self, T.A6.self)
109+
}

0 commit comments

Comments
 (0)