1- // RUN: %target-typecheck-verify-swift -warn-redundant-requirements
1+ // RUN: %target-typecheck-verify-swift
22// RUN: not %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s
33
44protocol Fooable {
@@ -57,7 +57,6 @@ func test2a<T: Fooable, U: Fooable>(_ t: T, u: U) -> (X, X)
5757// CHECK-NEXT: Generic signature: <T, U where T : Fooable, U : Fooable, T.[Fooable]Foo == X, U.[Fooable]Foo == X>
5858func test3< T: Fooable , U: Fooable > ( _ t: T , u: U ) -> ( X , X )
5959 where T. Foo == X , U. Foo == X , T. Foo == U . Foo {
60- // expected-warning@-1{{redundant same-type constraint 'T.Foo' == 'X'}}
6160 return ( t. foo, u. foo)
6261}
6362
@@ -101,7 +100,6 @@ func test6<T: Barrable>(_ t: T) -> (Y, X) where T.Bar == Y {
101100// CHECK-LABEL: same_types.(file).test7@
102101// CHECK-NEXT: Generic signature: <T where T : Barrable, T.[Barrable]Bar == Y>
103102func test7< T: Barrable > ( _ t: T ) -> ( Y , X ) where T. Bar == Y , T. Bar. Foo == X {
104- // expected-warning@-1{{redundant same-type constraint 'Y.Foo' (aka 'X') == 'X'}}
105103 return ( t. bar, t. bar. foo)
106104}
107105
@@ -143,7 +141,7 @@ func fail6<T>(_ t: T) -> Int where T == Int { // expected-warning{{same-type req
143141// CHECK-NEXT: Generic signature: <T, U where T : Barrable, U : Barrable, T.[Barrable]Bar == Y, U.[Barrable]Bar == Y>
144142func test8< T: Barrable , U: Barrable > ( _ t: T , u: U ) -> ( Y , Y , X , X )
145143 where T. Bar == Y ,
146- U. Bar. Foo == X , T. Bar == U . Bar { // expected-warning{{redundant same-type constraint 'U.Bar.Foo' == 'X'}}
144+ U. Bar. Foo == X , T. Bar == U . Bar {
147145 return ( t. bar, u. bar, t. bar. foo, u. bar. foo)
148146}
149147
@@ -152,14 +150,14 @@ func test8<T: Barrable, U: Barrable>(_ t: T, u: U) -> (Y, Y, X, X)
152150func test8a< T: Barrable , U: Barrable > ( _ t: T , u: U ) -> ( Y , Y , X , X )
153151 where
154152 T. Bar == Y ,
155- U. Bar. Foo == X , U. Bar == T . Bar { // expected-warning{{redundant same-type constraint 'U.Bar.Foo' == 'X'}}
153+ U. Bar. Foo == X , U. Bar == T . Bar {
156154 return ( t. bar, u. bar, t. bar. foo, u. bar. foo)
157155}
158156
159157// CHECK-LABEL: same_types.(file).test8b(_:u:)@
160158// CHECK-NEXT: Generic signature: <T, U where T : Barrable, U : Barrable, T.[Barrable]Bar == Y, U.[Barrable]Bar == Y>
161159func test8b< T: Barrable , U: Barrable > ( _ t: T , u: U )
162- where U. Bar. Foo == X , // expected-warning{{redundant same-type constraint 'U.Bar.Foo' == 'X'}}
160+ where U. Bar. Foo == X ,
163161 T. Bar == Y ,
164162 T. Bar == U . Bar {
165163}
@@ -205,7 +203,6 @@ struct S2<T : P> where T.A == T.B {
205203 // CHECK-LABEL: same_types.(file).S2.foo(x:y:)@
206204 // CHECK-NEXT: <T, X, Y where T : P, X == Y, Y == T.[P]A, T.[P]A == T.[P]B>
207205 func foo< X, Y> ( x: X , y: Y ) where X == T . A , Y == T . B { // expected-warning{{same-type requirement makes generic parameters 'Y' and 'X' equivalent}}
208- // expected-warning@-1 {{redundant same-type constraint 'X' == 'T.A'}}
209206 print ( X . self)
210207 print ( Y . self)
211208 print ( x)
@@ -278,7 +275,6 @@ func structuralSameType3<T, U, V, W>(_: T, _: U, _: V, _: W)
278275 where X1 < T , U > == X1 < V , W > { }
279276// expected-warning@-2{{same-type requirement makes generic parameters 'V' and 'T' equivalent}}
280277// expected-warning@-3{{same-type requirement makes generic parameters 'W' and 'U' equivalent}}
281- // expected-warning@-3{{redundant same-type constraint 'X1<T, U>' == 'X1<V, W>'}}
282278
283279protocol P2 {
284280 associatedtype Assoc1
@@ -337,7 +333,6 @@ func test9<T: P6, U: P6>(_ t: T, u: U) // expected-error{{no type for 'T.Bar.Foo
337333func testMetatypeSameType< T, U> ( _ t: T , _ u: U )
338334 where T. Type == U . Type { }
339335// expected-warning@-2{{same-type requirement makes generic parameters 'U' and 'T' equivalent}}
340- // expected-warning@-2{{redundant same-type constraint 'T.Type' == 'U.Type'}}
341336
342337// CHECK-LABEL: same_types.(file).testSameTypeCommutativity1@
343338// CHECK-NEXT: Generic signature: <U, T where U == T.Type>
0 commit comments