1+ // RUN: %target-typecheck-verify-swift
2+ // RUN: %target-swift-frontend -debug-generic-signatures -typecheck %s 2>&1 | %FileCheck %s
3+
4+ protocol P { }
5+ class C { }
6+
7+ class X < T : P > : U { }
8+ class Y < T : C > : V { }
9+ class Z < T : AnyObject > : W { }
10+
11+ protocol U {
12+ associatedtype T : P
13+ }
14+
15+ protocol V {
16+ associatedtype T : C
17+ }
18+
19+ protocol W {
20+ associatedtype T : AnyObject
21+ }
22+
23+ // CHECK: Generic signature: <A, B where A : X<B>, B : P>
24+ func derivedViaConcreteX1< A, B> ( _: A , _: B )
25+ where A : U , A : X < B > { }
26+ // expected-warning@-1 {{redundant conformance constraint 'A' : 'U'}}
27+ // expected-note@-2 {{conformance constraint 'A' : 'U' implied here}}
28+
29+ // FIXME: We should not diagnose 'B : P' as redundant, even though it
30+ // really is, because it was made redundant by an inferred requirement.
31+
32+ // CHECK: Generic signature: <A, B where A : X<B>, B : P>
33+ func derivedViaConcreteX2< A, B> ( _: A , _: B )
34+ where A : U , B : P , A : X < B > { }
35+ // expected-warning@-1 {{redundant conformance constraint 'A' : 'U'}}
36+ // expected-note@-2 {{conformance constraint 'A' : 'U' implied here}}
37+ // expected-warning@-3 {{redundant conformance constraint 'B' : 'P'}}
38+ // expected-note@-4 {{conformance constraint 'B' : 'P' implied here}}
39+
40+ // CHECK: Generic signature: <A, B where A : Y<B>, B : C>
41+ func derivedViaConcreteY1< A, B> ( _: A , _: B )
42+ where A : V , A : Y < B > { }
43+ // expected-warning@-1 {{redundant conformance constraint 'A' : 'V'}}
44+ // expected-note@-2 {{conformance constraint 'A' : 'V' implied here}}
45+
46+ // FIXME: We should not diagnose 'B : C' as redundant, even though it
47+ // really is, because it was made redundant by an inferred requirement.
48+
49+ // CHECK: Generic signature: <A, B where A : Y<B>, B : C>
50+ func derivedViaConcreteY2< A, B> ( _: A , _: B )
51+ where A : V , B : C , A : Y < B > { }
52+ // expected-warning@-1 {{redundant conformance constraint 'A' : 'V'}}
53+ // expected-note@-2 {{conformance constraint 'A' : 'V' implied here}}
54+ // expected-warning@-3 {{redundant superclass constraint 'B' : 'C'}}
55+ // expected-note@-4 {{superclass constraint 'B' : 'C' implied here}}
56+
57+ // CHECK: Generic signature: <A, B where A : Z<B>, B : AnyObject>
58+ func derivedViaConcreteZ1< A, B> ( _: A , _: B )
59+ where A : W , A : Z < B > { }
60+ // expected-warning@-1 {{redundant conformance constraint 'A' : 'W'}}
61+ // expected-note@-2 {{conformance constraint 'A' : 'W' implied here}}
62+
63+ // CHECK: Generic signature: <A, B where A : Z<B>, B : AnyObject>
64+ func derivedViaConcreteZ2< A, B> ( _: A , _: B )
65+ where A : W , B : AnyObject , A : Z < B > { }
66+ // expected-warning@-1 {{redundant conformance constraint 'A' : 'W'}}
67+ // expected-note@-2 {{conformance constraint 'A' : 'W' implied here}}
0 commit comments