File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
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 ( )
You can’t perform that action at this time.
0 commit comments