Skip to content

Commit 2930734

Browse files
committed
Add regression test for a fixed crasher
1 parent 3644a5e commit 2930734

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
public protocol SomeProto {
4+
associatedtype ThingType
5+
func getThing() -> ThingType
6+
}
7+
8+
public protocol SpecialThing: RandomAccessCollection {
9+
}
10+
11+
public protocol Castable {
12+
associatedtype Source
13+
static func cast(from: Source) -> Self
14+
}
15+
16+
public struct ThingGetter<P: SomeProto, T> {
17+
public let thing: P
18+
}
19+
20+
extension ThingGetter where P.ThingType: SpecialThing, T: Castable, P.ThingType.Iterator.Element == T.Source {
21+
22+
public func getView() -> ThingView {
23+
return ThingView(thing: thing.getThing())
24+
}
25+
26+
public struct ThingView: SpecialThing {
27+
let thing: P.ThingType
28+
29+
public typealias Index = P.ThingType.Index
30+
public var startIndex: Index { return thing.startIndex }
31+
public var endIndex: Index { return thing.startIndex }
32+
public var count: Int { return thing.count }
33+
public func index(after i: Index) -> Index {
34+
return thing.index(after: i)
35+
}
36+
public func index(before i: Index) -> Index {
37+
return thing.index(before: i)
38+
}
39+
public subscript(i: Index) -> T {
40+
return T.cast(from: thing[i])
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)