Skip to content

Commit 927d099

Browse files
committed
Add regression test to close #52024
1 parent 4bcb371 commit 927d099

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/decl/protocol/req/associated_type_inference_proto_ext.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %target-typecheck-verify-swift
22

3+
func assertEqualTypes<T>(_: T.Type, _: T.Type) {}
4+
35
struct Pair<A, B> {
46
var a: A
57
var b: B
@@ -28,3 +30,33 @@ extension Pair: Collection where A == B {
2830
return i + 1
2931
}
3032
}
33+
34+
// https://github.com/apple/swift/issues/52024
35+
protocol VectorBase : RandomAccessCollection where Index == Int, Element == Elle {
36+
associatedtype Elle
37+
38+
var data: Array<Elle> { get set }
39+
init(data: Array<Elle>)
40+
}
41+
42+
protocol Vector: VectorBase {}
43+
extension Vector where Elle: FloatingPoint {
44+
// RandomAccessCollection
45+
var indices: Range<Int> { get {} }
46+
var startIndex: Int { get {} }
47+
var endIndex: Int { get {} }
48+
49+
// MutableCollection
50+
subscript(i: Index) -> Elle {
51+
get {} set {}
52+
}
53+
}
54+
55+
do {
56+
struct VectorF: Vector {
57+
var data: Array<Float>
58+
init(data: Array<Float>) {}
59+
}
60+
61+
assertEqualTypes(VectorF.Elle.self, Float.self)
62+
}

0 commit comments

Comments
 (0)