Skip to content

Commit 82d95ec

Browse files
[tests] Adding regression tests for SR-13226
1 parent 81afffe commit 82d95ec

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/Generics/sr13226.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

0 commit comments

Comments
 (0)