Skip to content

Commit c12b766

Browse files
committed
Add test for SR-8022
1 parent 4a8fb79 commit c12b766

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: %target-run-simple-swift
2+
// REQUIRES: executable_test
3+
4+
5+
struct X: BidirectionalCollection {
6+
var startIndex: Int { return 0 }
7+
var endIndex: Int { return 10 }
8+
subscript(position: Int) -> String { return "element" }
9+
subscript(range: Range<Int>) -> X { return X() }
10+
func index(after i: Int) -> Int { return i + 1 }
11+
func index(before i: Int) -> Int { return i - 1 }
12+
}
13+
struct A<C: Collection>: Collection {
14+
let c: C
15+
var startIndex: C.Index { return c.startIndex }
16+
var endIndex: C.Index { return c.endIndex }
17+
subscript(position: C.Index) -> C.Element { return c[position] }
18+
subscript(range: Range<C.Index>) -> A<C.SubSequence> {
19+
return A<C.SubSequence>(c: c[range])
20+
}
21+
func index(after i: C.Index) -> C.Index { return c.index(after: i) }
22+
}
23+
24+
extension A: BidirectionalCollection where C: BidirectionalCollection {
25+
func index(before i: C.Index) -> C.Index { return c.index(before: i) }
26+
}
27+
28+
// SR-8022
29+
func sr8022() {
30+
var c = A(c: X())
31+
_ = c.popLast()
32+
_ = c.removeLast()
33+
c.removeLast(2)
34+
_ = c.dropLast(2)
35+
_ = c.suffix(2)
36+
}
37+
38+
sr8022()

0 commit comments

Comments
 (0)