File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+ struct W < T> { }
3
+
4
+ struct S < C1: Collection > {
5
+ init ( ) { }
6
+ // expected-note@+2 {{where 'C1.Element' = 'String', 'W<C2.Element>' = 'Int'}}
7
+ // expected-note@+1 {{where 'C1.Element' = 'C1', 'W<C2.Element>' = 'C2.Element'}}
8
+ init < C2> ( _ c2: W < C2 > ) where C2: Collection , C1. Element == W < C2 . Element > { }
9
+ // expected-note@+1 {{where 'C1.Element' = 'String', 'W<C2.Element>' = 'Int'}}
10
+ static func f< C2> ( _ c2: W < C2 > ) where C2: Collection , C1. Element == W < C2 . Element > { }
11
+ // expected-note@+1 {{where 'C1.Element' = 'String', 'W<C2.Element>' = 'Int'}}
12
+ func instancef< C2> ( _ c2: W < C2 > ) where C2: Collection , C1. Element == W < C2 . Element > { }
13
+ }
14
+ let _ = S < [ W < String > ] > ( W < [ Int ] > ( ) ) // expected-error{{initializer 'init(_:)' requires the types 'String' and 'Int' be equivalent}}
15
+ let _ = S < [ W < String > ] > . f ( W < [ Int ] > ( ) ) // expected-error{{static method 'f' requires the types 'String' and 'Int' be equivalent}}
16
+ let _ = S < [ W < String > ] > ( ) . instancef ( W < [ Int ] > ( ) ) // expected-error{{instance method 'instancef' requires the types 'String' and 'Int' be equivalent}}
17
+
18
+ // Archetypes requirement failure
19
+ func genericFunc< C1: Collection , C2: Collection > ( _ c2: W < C2 > , c1: C1 . Type ) where C1. Element == W < C2 . Element > {
20
+ let _ = S < [ W < C1 > ] > ( W < C2 > ( ) ) // expected-error{{initializer 'init(_:)' requires the types 'C1' and 'C2.Element' be equivalent}}
21
+ }
You can’t perform that action at this time.
0 commit comments