@@ -58,14 +58,16 @@ func test3<T: Fooable, U: Fooable>(_ t: T, u: U) -> (X, X)
5858func fail1<
5959 T: Fooable , U: Fooable
6060> ( _ t: T , u: U ) -> ( X , Y )
61- where T. Foo == X , U. Foo == Y , T. Foo == U . Foo { // expected-error{{associated type 'T.Foo' cannot be equal to both 'X' and 'Y'}}
61+ where T. Foo == X , U. Foo == Y , T. Foo == U . Foo { // expected-error{{'U.Foo' cannot be equal to both 'Y' and 'X'}}
62+ // expected-note@-1{{same-type constraint 'T.Foo' == 'X' written here}}
6263 return ( t. foo, u. foo) // expected-error{{cannot convert return expression of type 'X' to return type 'Y'}}
6364}
6465
6566func fail2<
6667 T: Fooable , U: Fooable
6768> ( _ t: T , u: U ) -> ( X , Y )
68- where T. Foo == U . Foo , T. Foo == X , U. Foo == Y { // expected-error{{associated type 'U.Foo' cannot be equal to both 'X' and 'Y'}}
69+ where T. Foo == U . Foo , T. Foo == X , U. Foo == Y { // expected-error{{'U.Foo' cannot be equal to both 'Y' and 'X'}}
70+ // expected-note@-1{{same-type constraint 'T.Foo' == 'X' written here}}
6971 return ( t. foo, u. foo) // expected-error{{cannot convert return expression of type 'X' to return type 'Y'}}
7072}
7173
@@ -94,20 +96,22 @@ func test7<T: Barrable>(_ t: T) -> (Y, X) where T.Bar == Y, T.Bar.Foo == X {
9496
9597func fail4< T: Barrable > ( _ t: T ) -> ( Y , Z )
9698 where
97- T. Bar == Y ,
98- T. Bar. Foo == Z { // expected-error{{associated type 'T.Bar.Foo' cannot be equal to both 'Y.Foo' (aka 'X') and 'Z' }}
99+ T. Bar == Y , // expected-note{{same-type constraint 'T.Bar.Foo' == 'Y.Foo' (aka 'X') implied here}}
100+ T. Bar. Foo == Z { // expected-error{{'T.Bar.Foo' cannot be equal to both 'Z' and ' Y.Foo' (aka 'X')}}
99101 return ( t. bar, t. bar. foo) // expected-error{{cannot convert return expression of type 'X' to return type 'Z'}}
100102}
101103
102104func fail5< T: Barrable > ( _ t: T ) -> ( Y , Z )
103105 where
104- T. Bar. Foo == Z , // expected-warning{{redundant same-type constraint 'T.Bar.Foo' == 'Z'}}
105- T. Bar == Y { // expected-error{{associated type 'T.Bar.Foo' cannot be equal to both 'Z' and 'X'}}
106- // expected-note@-1{{same-type constraint 'T.Bar.Foo' == 'Y.Foo' (aka 'X') implied here}}
106+ T. Bar. Foo == Z , // expected-note{{same-type constraint 'T.Bar.Foo' == 'Z' written here}}
107+ T. Bar == Y { // expected-error{{'T.Bar.Foo' cannot be equal to both 'Y.Foo' (aka 'X') and 'Z'}}
107108 return ( t. bar, t. bar. foo) // expected-error{{cannot convert return expression of type 'X' to return type 'Z'}}
108109}
109110
110- func test8< T: Fooable > ( _ t: T ) where T. Foo == X , T. Foo == Y { } // expected-error{{associated type 'T.Foo' cannot be equal to both 'X' and 'Y'}}
111+ func test8< T: Fooable > ( _ t: T )
112+ where T. Foo == X , // expected-note{{same-type constraint 'T.Foo' == 'X' written here}}
113+ T. Foo == Y { } // expected-error{{'T.Foo' cannot be equal to both 'Y' and 'X'}}
114+
111115
112116func testAssocTypeEquivalence< T: Fooable > ( _ fooable: T ) -> X . Type
113117 where T. Foo == X {
@@ -246,7 +250,6 @@ func structuralSameTypeRecursive1<T: P2, U>(_: T, _: U)
246250 where T. Assoc1 == Tuple2 < T . Assoc1 , U > // expected-error{{same-type constraint 'T.Assoc1' == '(T.Assoc1, U)' is recursive}}
247251{ }
248252
249-
250253protocol P3 {
251254}
252255
@@ -256,5 +259,25 @@ protocol P4 {
256259
257260func 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'}}
258261
262+ // Same-type constraint conflict through protocol where clauses.
263+ protocol P5 where Foo1 == Foo2 {
264+ associatedtype Foo1
265+ associatedtype Foo2
266+ }
267+
268+ protocol P6 {
269+ associatedtype Bar : P5
270+ }
271+
272+ struct X5a { }
273+
274+ struct X5b { }
275+
276+ func test9< T: P6 , U: P6 > ( _ t: T , u: U )
277+ where T. Bar. Foo1 == X5a , // expected-note{{same-type constraint 'T.Bar.Foo1' == 'X5a' written here}}
278+ U. Bar. Foo2 == X5b , // expected-error{{'U.Bar.Foo2' cannot be equal to both 'X5b' and 'X5a'}}
279+ T. Bar == U . Bar {
280+ }
281+
259282// FIXME: Remove -verify-ignore-unknown.
260283// <unknown>:0: error: unexpected error produced: generic parameter τ_0_0.Bar.Foo cannot be equal to both 'Y.Foo' (aka 'X') and 'Z'
0 commit comments