Skip to content

Commit 4ad9b48

Browse files
committed
[CSSolver] NFC: Add more test-cases for requirement checking in constrained extensions
1 parent d573309 commit 4ad9b48

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/Constraints/rdar39931339.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,38 @@ protocol P {}
44

55
struct S<T> {}
66

7-
class A : P {}
7+
class C : P {}
88

99
extension S where T : P {
1010
typealias A = Int
1111
typealias B<U> = S<U>
1212
}
1313

14-
_ = S<A>.A() // Ok
14+
extension S where T == Float {
15+
typealias C = Int
16+
}
17+
18+
class A<T, U> {}
19+
20+
extension A where T == [U], U: P {
21+
typealias S1 = Int
22+
}
23+
24+
extension A where T == [U], U == Int {
25+
typealias S2 = Int
26+
}
27+
28+
class B<U> : A<[U], U> {}
29+
30+
_ = B<C>.S1() // Ok
31+
_ = B<Int>.S2() // Ok
32+
_ = B<Float>.S1() // expected-error {{type 'Float' does not conform to protocol 'P'}}
33+
_ = B<String>.S2() // expected-error {{'B<String>.S2.Type' (aka 'Int.Type') requires the types '[String]' and '[Int]' be equivalent}}
34+
35+
_ = S<C>.A() // Ok
1536
_ = S<Int>.A() // expected-error {{type 'Int' does not conform to protocol 'P'}}
1637
_ = S<String>.B<Int>() // expected-error {{type 'String' does not conform to protocol 'P'}}
38+
_ = S<Int>.C() // expected-error {{'S<Int>.C.Type' (aka 'Int.Type') requires the types 'Int' and 'Float' be equivalent}}
1739

1840
func foo<T>(_ s: S<T>.Type) {
1941
_ = s.A() // expected-error {{type 'T' does not conform to protocol 'P'}}

0 commit comments

Comments
 (0)