Skip to content

Commit 96fd043

Browse files
committed
Add tests for multiple @_implements on associated types
1 parent 355adfe commit 96fd043

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/decl/protocol/req/associated_type_typealias_implements.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,33 @@ struct Y3: Q { // expected-error{{type 'Y3' does not conform to protocol 'Q'}}
3636
typealias T = XT
3737
// FIXME: More detail from diagnostic.
3838
}
39+
40+
41+
protocol A1 {
42+
associatedtype T
43+
}
44+
protocol A2 {
45+
associatedtype T
46+
}
47+
48+
struct BothA1_and_A2: A1, A2 {
49+
@_implements(A1, T)
50+
typealias X = Int
51+
52+
@_implements(A2, T)
53+
typealias Y = String
54+
}
55+
56+
typealias A1_T<U: A1> = U.T
57+
typealias A2_T<U: A2> = U.T
58+
59+
struct RequireSame<T, U> { }
60+
61+
extension RequireSame where T == U {
62+
init(same: Bool) { }
63+
}
64+
65+
func testImplements() {
66+
_ = RequireSame<A1_T<BothA1_and_A2>, Int>(same: true)
67+
_ = RequireSame<A2_T<BothA1_and_A2>, String>(same: true)
68+
}

0 commit comments

Comments
 (0)