Skip to content

Commit 305a1e4

Browse files
committed
RequirementMachine: Update some tests to pass with -requirement-machine-inferred-signatures=verify
1 parent 6a74ad7 commit 305a1e4

File tree

10 files changed

+131
-44
lines changed

10 files changed

+131
-44
lines changed

test/Constraints/same_types.swift

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=off
2+
// RUN: not %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
23

34
protocol Fooable {
45
associatedtype Foo // expected-note{{protocol requires nested type 'Foo'; do you want to add it?}}
@@ -38,23 +39,31 @@ struct NestedConstraint<T> {
3839
}
3940
}
4041

42+
// CHECK-LABEL: same_types.(file).test2(_:u:)@
43+
// CHECK-NEXT: Generic signature: <T, U where T : Fooable, U : Fooable, T.[Fooable]Foo == X, U.[Fooable]Foo == X>
4144
func test2<T: Fooable, U: Fooable>(_ t: T, u: U) -> (X, X)
4245
where T.Foo == X, U.Foo == T.Foo {
4346
return (t.foo, u.foo)
4447
}
4548

49+
// CHECK-LABEL: same_types.(file).test2a(_:u:)@
50+
// CHECK-NEXT: Generic signature: <T, U where T : Fooable, U : Fooable, T.[Fooable]Foo == X, U.[Fooable]Foo == X>
4651
func test2a<T: Fooable, U: Fooable>(_ t: T, u: U) -> (X, X)
4752
where T.Foo == X, T.Foo == U.Foo {
4853
return (t.foo, u.foo)
4954
}
5055

56+
// CHECK-LABEL: same_types.(file).test3(_:u:)@
57+
// CHECK-NEXT: Generic signature: <T, U where T : Fooable, U : Fooable, T.[Fooable]Foo == X, U.[Fooable]Foo == X>
5158
func test3<T: Fooable, U: Fooable>(_ t: T, u: U) -> (X, X)
5259
where T.Foo == X, U.Foo == X, T.Foo == U.Foo {
5360
// expected-warning@-1{{redundant same-type constraint 'U.Foo' == 'X'}}
5461
// expected-note@-2{{same-type constraint 'T.Foo' == 'X' written here}}
5562
return (t.foo, u.foo)
5663
}
5764

65+
// CHECK-LABEL: same_types.(file).fail1(_:u:)@
66+
// CHECK-NEXT: Generic signature: <T, U where T : Fooable, U : Fooable, T.[Fooable]Foo == U.[Fooable]Foo>
5867
func fail1<
5968
T: Fooable, U: Fooable
6069
>(_ t: T, u: U) -> (X, Y)
@@ -63,6 +72,8 @@ func fail1<
6372
return (t.foo, u.foo) // expected-error{{cannot convert return expression of type '(X, X)' to return type '(X, Y)'}}
6473
}
6574

75+
// CHECK-LABEL: same_types.(file).fail2(_:u:)@
76+
// CHECK-NEXT: Generic signature: <T, U where T : Fooable, U : Fooable, T.[Fooable]Foo == U.[Fooable]Foo>
6677
func fail2<
6778
T: Fooable, U: Fooable
6879
>(_ t: T, u: U) -> (X, Y)
@@ -75,6 +86,8 @@ func test4<T: Barrable>(_ t: T) -> Y where T.Bar == Y {
7586
return t.bar
7687
}
7788

89+
// CHECK-LABEL: same_types.(file).fail3@
90+
// CHECK-NEXT: Generic signature: <T where T : Barrable>
7891
func fail3<T: Barrable>(_ t: T) -> X
7992
where T.Bar == X { // expected-error {{'X' does not conform to required protocol 'Fooable'}}
8093
return t.bar // expected-error{{cannot convert return expression of type 'T.Bar' }}
@@ -88,25 +101,33 @@ func test6<T: Barrable>(_ t: T) -> (Y, X) where T.Bar == Y {
88101
return (t.bar, t.bar.foo)
89102
}
90103

104+
// CHECK-LABEL: same_types.(file).test7@
105+
// CHECK-NEXT: Generic signature: <T where T : Barrable, T.[Barrable]Bar == Y>
91106
func test7<T: Barrable>(_ t: T) -> (Y, X) where T.Bar == Y, T.Bar.Foo == X {
92107
// expected-warning@-1{{neither type in same-type constraint ('Y.Foo' (aka 'X') or 'X') refers to a generic parameter or associated type}}
93108
return (t.bar, t.bar.foo)
94109
}
95110

111+
// CHECK-LABEL: same_types.(file).fail4@
112+
// CHECK-NEXT: Generic signature: <T where T : Barrable, T.[Barrable]Bar == Y>
96113
func fail4<T: Barrable>(_ t: T) -> (Y, Z)
97114
where
98115
T.Bar == Y,
99116
T.Bar.Foo == Z { // expected-error{{generic signature requires types 'Y.Foo' (aka 'X') and 'Z' to be the same}}
100117
return (t.bar, t.bar.foo) // expected-error{{cannot convert return expression of type '(Y, X)' to return type '(Y, Z)'}}
101118
}
102119

120+
// CHECK-LABEL: same_types.(file).fail5@
121+
// CHECK-NEXT: Generic signature: <T where T : Barrable, T.[Barrable]Bar == Y>
103122
func fail5<T: Barrable>(_ t: T) -> (Y, Z)
104123
where
105124
T.Bar.Foo == Z, // expected-note{{same-type constraint 'T.Bar.Foo' == 'Z' written here}}
106125
T.Bar == Y { // expected-error{{'T.Bar.Foo' cannot be equal to both 'Y.Foo' (aka 'X') and 'Z'}}
107126
return (t.bar, t.bar.foo) // expected-error{{cannot convert return expression of type '(Y, X)' to return type '(Y, Z)'}}
108127
}
109128

129+
// CHECK-LABEL: same_types.(file).test8@
130+
// CHECK-NEXT: Generic signature: <T where T : Fooable>
110131
func test8<T: Fooable>(_ t: T)
111132
where T.Foo == X, // expected-note{{same-type constraint 'T.Foo' == 'X' written here}}
112133
T.Foo == Y {} // expected-error{{'T.Foo' cannot be equal to both 'Y' and 'X'}}
@@ -121,19 +142,25 @@ func fail6<T>(_ t: T) -> Int where T == Int { // expected-error{{same-type requi
121142
return t
122143
}
123144

145+
// CHECK-LABEL: same_types.(file).test8(_:u:)@
146+
// CHECK-NEXT: Generic signature: <T, U where T : Barrable, U : Barrable, T.[Barrable]Bar == Y, U.[Barrable]Bar == Y>
124147
func test8<T: Barrable, U: Barrable>(_ t: T, u: U) -> (Y, Y, X, X)
125148
where T.Bar == Y, // expected-note{{same-type constraint 'U.Bar.Foo' == 'Y.Foo' (aka 'X') implied here}}
126149
U.Bar.Foo == X, T.Bar == U.Bar { // expected-warning{{redundant same-type constraint 'U.Bar.Foo' == 'X'}}
127150
return (t.bar, u.bar, t.bar.foo, u.bar.foo)
128151
}
129152

153+
// CHECK-LABEL: same_types.(file).test8a(_:u:)@
154+
// CHECK-NEXT: Generic signature: <T, U where T : Barrable, U : Barrable, T.[Barrable]Bar == Y, U.[Barrable]Bar == Y>
130155
func test8a<T: Barrable, U: Barrable>(_ t: T, u: U) -> (Y, Y, X, X)
131156
where
132157
T.Bar == Y, // expected-note{{same-type constraint 'U.Bar.Foo' == 'Y.Foo' (aka 'X') implied here}}
133158
U.Bar.Foo == X, U.Bar == T.Bar { // expected-warning{{redundant same-type constraint 'U.Bar.Foo' == 'X'}}
134159
return (t.bar, u.bar, t.bar.foo, u.bar.foo)
135160
}
136161

162+
// CHECK-LABEL: same_types.(file).test8b(_:u:)@
163+
// CHECK-NEXT: Generic signature: <T, U where T : Barrable, U : Barrable, T.[Barrable]Bar == Y, U.[Barrable]Bar == Y>
137164
func test8b<T: Barrable, U: Barrable>(_ t: T, u: U)
138165
where U.Bar.Foo == X, // expected-warning{{redundant same-type constraint 'U.Bar.Foo' == 'X'}}
139166
T.Bar == Y, // expected-note{{same-type constraint 'U.Bar.Foo' == 'Y.Foo' (aka 'X') implied here}}
@@ -166,6 +193,8 @@ struct Q : P {
166193
}
167194

168195
struct S1<T : P> {
196+
// CHECK-LABEL: same_types.(file).S1.foo(x:y:)@
197+
// CHECK-NEXT: Generic signature: <T, X, Y where T : P, X == T.[P]A, Y == T.[P]B>
169198
func foo<X, Y>(x: X, y: Y) where X == T.A, Y == T.B {
170199
print(X.self)
171200
print(Y.self)
@@ -176,6 +205,8 @@ struct S1<T : P> {
176205
S1<Q>().foo(x: 1, y: 2)
177206

178207
struct S2<T : P> where T.A == T.B {
208+
// CHECK-LABEL: same_types.(file).S2.foo(x:y:)@
209+
// CHECK-NEXT: <T, X, Y where T : P, X == Y, Y == T.[P]A, T.[P]A == T.[P]B>
179210
func foo<X, Y>(x: X, y: Y) where X == T.A, Y == T.B { // expected-error{{same-type requirement makes generic parameters 'X' and 'Y' equivalent}}
180211
print(X.self)
181212
print(Y.self)
@@ -186,6 +217,8 @@ struct S2<T : P> where T.A == T.B {
186217
S2<Q>().foo(x: 1, y: 2)
187218

188219
struct S3<T : P> {
220+
// CHECK-LABEL: same_types.(file).S3.foo(x:y:)@
221+
// CHECK-NEXT: <T, X, Y where T : P, X == Y, Y == T.[P]A>
189222
func foo<X, Y>(x: X, y: Y) where X == T.A, Y == T.A {} // expected-error{{same-type requirement makes generic parameters 'X' and 'Y' equivalent}}
190223
}
191224
S3<Q>().foo(x: 1, y: 2)
@@ -208,6 +241,8 @@ struct QQ : P {
208241
}
209242

210243
struct S4<T : P> {
244+
// CHECK-LABEL: same_types.(file).S4.foo(x:)@
245+
// CHECK-NEXT: Generic signature: <T, X where T : P, X : PP, T.[P]A == X.[PP]A>
211246
func foo<X : PP>(x: X) where X.A == T.A {
212247
print(x)
213248
print(X.self)
@@ -223,18 +258,24 @@ protocol P1 {
223258
associatedtype Assoc
224259
}
225260

261+
// CHECK-LABEL: same_types.(file).structuralSameType1@
262+
// CHECK-NEXT: Generic signature: <A, B, T, U, V, W where A : P1, B : P1, T == V, U == W, A.[P1]Assoc == X1<T, U>, B.[P1]Assoc == X1<T, U>>
226263
func structuralSameType1<A: P1, B: P1, T, U, V, W>(_: A, _: B, _: T, _: U, _: V, _: W)
227264
where A.Assoc == X1<T, U>, B.Assoc == X1<V, W>, A.Assoc == B.Assoc { }
228265
// expected-error@-1{{same-type requirement makes generic parameters 'T' and 'V' equivalent}}
229266
// expected-error@-2{{same-type requirement makes generic parameters 'U' and 'W' equivalent}}
230267

231268
typealias Tuple2<T, U> = (T, U)
232269

270+
// CHECK-LABEL: same_types.(file).structuralSameType2@
271+
// CHECK-NEXT: Generic signature: <A, B, T, U, V, W where A : P1, B : P1, T == V, U == W, A.[P1]Assoc == (T, U), B.[P1]Assoc == (T, U)>
233272
func structuralSameType2<A: P1, B: P1, T, U, V, W>(_: A, _: B, _: T, _: U, _: V, _: W)
234273
where A.Assoc == Tuple2<T, U>, B.Assoc == Tuple2<V, W>, A.Assoc == B.Assoc { }
235274
// expected-error@-1{{same-type requirement makes generic parameters 'T' and 'V' equivalent}}
236275
// expected-error@-2{{same-type requirement makes generic parameters 'U' and 'W' equivalent}}
237276

277+
// CHECK-LABEL: same_types.(file).structuralSameType3@
278+
// CHECK-NEXT: Generic signature: <T, U, V, W where T == V, U == W>
238279
func structuralSameType3<T, U, V, W>(_: T, _: U, _: V, _: W)
239280
where X1<T, U> == X1<V, W> { }
240281
// expected-error@-1{{same-type requirement makes generic parameters 'T' and 'V' equivalent}}
@@ -246,6 +287,8 @@ protocol P2 {
246287
associatedtype Assoc2
247288
}
248289

290+
// CHECK-LABEL: same_types.(file).structuralSameTypeRecursive1@
291+
// CHECK-NEXT: Generic signature: <T, U>
249292
func structuralSameTypeRecursive1<T: P2, U>(_: T, _: U)
250293
where T.Assoc1 == Tuple2<T.Assoc1, U> // expected-error{{same-type constraint 'T.Assoc1' == '(T.Assoc1, U)' is recursive}}
251294
{ }
@@ -257,6 +300,8 @@ protocol P4 {
257300
associatedtype A
258301
}
259302

303+
// CHECK-LABEL: same_types.(file).test9@
304+
// CHECK-NEXT: Generic signature: <T where T : P4>
260305
func test9<T>(_: T) where T.A == X, T: P4, T.A: P3 { } // expected-error{{same-type constraint type 'X' does not conform to required protocol 'P3'}}
261306

262307
// Same-type constraint conflict through protocol where clauses.
@@ -273,6 +318,8 @@ struct X5a {}
273318

274319
struct X5b { }
275320

321+
// CHECK-LABEL: same_types.(file).test9(_:u:)@
322+
// CHECK-NEXT: Generic signature: <T, U where T : P6, U : P6, T.[P6]Bar == U.[P6]Bar>
276323
func test9<T: P6, U: P6>(_ t: T, u: U)
277324
where T.Bar.Foo1 == X5a, // expected-note{{same-type constraint 'T.Bar.Foo1' == 'X5a' written here}}
278325
U.Bar.Foo2 == X5b, // expected-error{{'U.Bar.Foo2' cannot be equal to both 'X5b' and 'X5a'}}
@@ -282,36 +329,57 @@ func test9<T: P6, U: P6>(_ t: T, u: U)
282329
// FIXME: Remove -verify-ignore-unknown.
283330
// <unknown>:0: error: unexpected error produced: generic parameter τ_0_0.Bar.Foo cannot be equal to both 'Y.Foo' (aka 'X') and 'Z'
284331

332+
// CHECK-LABEL: same_types.(file).testMetatypeSameType@
333+
// CHECK-NEXT: Generic signature: <T, U where T == U>
285334
func testMetatypeSameType<T, U>(_ t: T, _ u: U)
286335
where T.Type == U.Type { }
287336
// expected-error@-1{{same-type requirement makes generic parameters 'T' and 'U' equivalent}}
288337
// expected-warning@-2{{neither type in same-type constraint ('T.Type' or 'U.Type') refers to a generic parameter or associated type}}
289338

339+
// CHECK-LABEL: same_types.(file).testSameTypeCommutativity1@
340+
// CHECK-NEXT: Generic signature: <U, T where U == T.Type>
290341
func testSameTypeCommutativity1<U, T>(_ t: T, _ u: U)
291342
where T.Type == U { } // Equivalent to U == T.Type
292343
// expected-error@-1{{same-type requirement makes generic parameter 'U' non-generic}}
293344

345+
// CHECK-LABEL: same_types.(file).testSameTypeCommutativity2@
346+
// CHECK-NEXT: Generic signature: <U, T where T : P1, T.[P1]Assoc == U?>
294347
func testSameTypeCommutativity2<U, T: P1>(_ t: T, _ u: U)
295348
where U? == T.Assoc { } // Ok, equivalent to T.Assoc == U?
296349

350+
// CHECK-LABEL: same_types.(file).testSameTypeCommutativity3@
351+
// CHECK-NEXT: Generic signature: <U, T where T : P1, T.[P1]Assoc == (U) -> ()>
297352
func testSameTypeCommutativity3<U, T: P1>(_ t: T, _ u: U)
298353
where (U) -> () == T.Assoc { } // Ok, equivalent to T.Assoc == (U) -> ()
299354

355+
// CHECK-LABEL: same_types.(file).testSameTypeCommutativity4@
356+
// CHECK-NEXT: Generic signature: <U, T where T == (U) -> ()>
300357
func testSameTypeCommutativity4<U, T>(_ t: T, _ u: U)
301358
where (U) -> () == T { } // Equivalent to T == (U) -> ()
302359
// expected-error@-1{{same-type requirement makes generic parameter 'T' non-generic}}
303360

361+
// CHECK-LABEL: same_types.(file).testSameTypeCommutativity5@
362+
// CHECK-NEXT: Generic signature: <U, T where T : P1, T.[P1]Assoc == P3 & PPP>
304363
func testSameTypeCommutativity5<U, T: P1>(_ t: T, _ u: U)
305364
where PPP & P3 == T.Assoc { } // Ok, equivalent to T.Assoc == PPP & P3
306365

366+
// CHECK-LABEL: same_types.(file).testSameTypeCommutativity6@
367+
// CHECK-NEXT: Generic signature: <U, T where T : P1>
307368
func testSameTypeCommutativity6<U, T: P1>(_ t: T, _ u: U)
308369
where U & P3 == T.Assoc { } // Equivalent to T.Assoc == U & P3
309370
// expected-error@-1 {{non-protocol, non-class type 'U' cannot be used within a protocol-constrained type}}
310371

311-
// rdar;//problem/46848889
372+
// rdar://problem/46848889
373+
374+
// CHECK-LABEL: same_types.(file).Foo@
375+
// CHECK-NEXT: Generic signature: <A, B, C where A : P1, B : P1, C : P1, A.[P1]Assoc == B.[P1]Assoc, B.[P1]Assoc == C.[P1]Assoc>
312376
struct Foo<A: P1, B: P1, C: P1> where A.Assoc == B.Assoc, A.Assoc == C.Assoc {}
313377

378+
// CHECK-LABEL: same_types.(file).Bar@
379+
// CHECK-NEXT: Generic signature: <A, B where A : P1, B : P1, A.[P1]Assoc == B.[P1]Assoc>
314380
struct Bar<A: P1, B: P1> where A.Assoc == B.Assoc {
381+
// CHECK-LABEL: same_types.(file).Bar.f(with:)@
382+
// CHECK-NEXT: Generic signature: <A, B, C where A : P1, B : P1, C : P1, A.[P1]Assoc == B.[P1]Assoc, B.[P1]Assoc == C.[P1]Assoc>
315383
func f<C: P1>(with other: C) -> Foo<A, B, C> where A.Assoc == C.Assoc {
316384
// expected-note@-1 {{previous same-type constraint 'B.Assoc' == 'C.Assoc' inferred from type here}}
317385
// expected-warning@-2 {{redundant same-type constraint 'A.Assoc' == 'C.Assoc'}}

test/Generics/protocol_typealias_concrete_unification.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=on
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
22

33
protocol P1 {
44
typealias T = Array<U>
@@ -9,4 +9,17 @@ protocol P2 {
99
typealias T = Array<Int>
1010
}
1111

12+
// Note that the GenericSignatureBuilder did not record the 'T.[P1]U == Int'
13+
// requirement. But I believe this is too aggressive.
14+
15+
// CHECK-LABEL: .foo(_:u:)@
16+
// CHECK-NEXT: Generic signature: <T where T : P1, T : P2, T.[P1]U == Int>
1217
func foo<T : P1 & P2>(_: T, u: T.U) -> Int { return u }
18+
19+
// CHECK-LABEL: .P3@
20+
// CHECK-NEXT: Requirement signature: <Self where Self : P1, Self : P2, Self.[P1]U == Int>
21+
protocol P3 : P1, P2 {}
22+
23+
// This conformance should succeed, and associated type inference should infer
24+
// 'S.U == Int'.
25+
struct S : P3 {}

test/Generics/rdar62903491.swift

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
// RUN: %target-typecheck-verify-swift
2-
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=on
2+
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
33

44
protocol P {
55
associatedtype X : P
66
}
77

88
// Anything that mentions 'T : P' and 'U : P' minimizes to 'U : P'.
99

10-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P'}}
11-
// expected-note@+1 {{conformance constraint 'U' : 'P' implied here}}
10+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P'}}
1211
func oneProtocol1<T, U>(_: T, _: U) where T : P, U : P, T.X == U, U.X == T {}
1312
// CHECK-LABEL: oneProtocol1
1413
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>
1514

16-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P'}}
17-
// expected-note@+1 {{conformance constraint 'U' : 'P' implied here}}
15+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P'}}
1816
func oneProtocol2<T, U>(_: T, _: U) where U : P, T : P, T.X == U, U.X == T {}
1917
// CHECK-LABEL: oneProtocol2
2018
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>
2119

22-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P'}}
23-
// expected-note@+1 {{conformance constraint 'U' : 'P' implied here}}
20+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P'}}
2421
func oneProtocol3<T, U>(_: T, _: U) where T : P, T.X == U, U : P, U.X == T {}
2522
// CHECK-LABEL: oneProtocol3
2623
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>
2724

28-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P'}}
29-
// expected-note@+1 {{conformance constraint 'U' : 'P' implied here}}
25+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P'}}
3026
func oneProtocol4<T, U>(_: T, _: U) where U : P, T.X == U, T : P, U.X == T {}
3127
// CHECK-LABEL: oneProtocol4
3228
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>
@@ -59,38 +55,43 @@ protocol P2 {
5955
associatedtype Y : P1
6056
}
6157

62-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P2'}}
63-
// expected-note@+1 {{conformance constraint 'U' : 'P2' implied here}}
58+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P2'}}
6459
func twoProtocols1<T, U>(_: T, _: U) where T : P1, U : P2, T.X == U, U.Y == T {}
6560
// CHECK-LABEL: twoProtocols1
6661
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>
6762

68-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P2'}}
69-
// expected-note@+1 {{conformance constraint 'U' : 'P2' implied here}}
63+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P2'}}
7064
func twoProtocols2<T, U>(_: T, _: U) where U : P2, T : P1, T.X == U, U.Y == T {}
7165
// CHECK-LABEL: twoProtocols2
7266
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>
7367

74-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P2'}}
75-
// expected-note@+1 {{conformance constraint 'U' : 'P2' implied here}}
68+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P2'}}
7669
func twoProtocols3<T, U>(_: T, _: U) where T : P1, T.X == U, U : P2, U.Y == T {}
7770
// CHECK-LABEL: twoProtocols3
7871
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>
7972

80-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P2'}}
81-
// expected-note@+1 {{conformance constraint 'U' : 'P2' implied here}}
73+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P2'}}
8274
func twoProtocols4<T, U>(_: T, _: U) where U : P2, T.X == U, T : P1, U.Y == T {}
8375
// CHECK-LABEL: twoProtocols4
8476
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>
8577

86-
// expected-warning@+2 {{redundant conformance constraint 'U' : 'P2'}}
87-
// expected-note@+1 {{conformance constraint 'U' : 'P2' implied here}}
78+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P2'}}
8879
func twoProtocols5<T, U>(_: T, _: U) where T : P1, T.X == U, U.Y == T, U : P2 {}
8980
// CHECK-LABEL: twoProtocols5
9081
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>
9182

92-
// expected-warning@+2 {{redundant conformance constraint 'T' : 'P1'}}
93-
// expected-note@+1 {{conformance constraint 'T' : 'P1' implied here}}
83+
// The GenericSignatureBuilder minimized this signature down to
84+
// <T, U where T == U.[P2]Y, U : P2, U == T.[P1]X>.
85+
//
86+
// The Requirement Machine instead emits
87+
// <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>.
88+
//
89+
// This is a hypothetical ABI break, but it is such a silly edge case that
90+
// it shouldn't matter in practice. Given that either of the two conformance
91+
// requirements here are redundant, the user can omit one or the other to
92+
// specify the result that they desire.
93+
94+
// expected-warning@+1 {{redundant conformance constraint 'U' : 'P2'}}
9495
func twoProtocols6<T, U>(_: T, _: U) where U : P2, T.X == U, U.Y == T, T : P1 {}
9596
// CHECK-LABEL: twoProtocols6
96-
// CHECK: Generic signature: <T, U where T == U.[P2]Y, U : P2, U == T.[P1]X>
97+
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>

test/Generics/rdar80503090.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=on
22
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
33
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s -requirement-machine-inferred-signatures=on -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
44

0 commit comments

Comments
 (0)