1
1
// RUN: %target-parse-verify-swift
2
2
3
- protocol P : Collection {
3
+ protocol MyIteratorProtocol {
4
+ associatedtype Element
5
+ func next( ) -> Element ?
6
+ }
7
+
8
+ protocol MySequence {
9
+ associatedtype Iterator : MyIteratorProtocol
10
+ }
11
+
12
+ protocol MyCollection : MySequence {
13
+ var startIndex : Iterator { get }
14
+ }
15
+
16
+ protocol P : MyCollection {
4
17
init ( )
5
18
}
6
19
postfix operator ~>> { }
7
20
8
- postfix func ~>> < _Self : Sequence , A : P where _Self. Iterator. Element == A . Iterator . Element > ( _: _Self ) -> A {
21
+ postfix func ~>> < _Self : MySequence , A : P where _Self. Iterator. Element == A . Iterator . Element > ( _: _Self ) -> A {
9
22
return A ( )
10
23
}
11
24
12
- protocol _ExtendedSequence : Sequence {
25
+ protocol _ExtendedSequence : MySequence {
13
26
postfix func ~>> < A : P where Self. Iterator. Element == A . Iterator . Element > ( s: Self ) -> A
14
27
}
15
28
16
- extension Range : _ExtendedSequence {
29
+ struct MyRangeIterator < T> : MyIteratorProtocol {
30
+ func next( ) -> T ? { return nil }
31
+ }
32
+
33
+ struct MyRange < T> : _ExtendedSequence {
34
+ typealias Element = T
35
+ typealias Iterator = MyRangeIterator < T >
17
36
}
18
37
19
- protocol Q : Sequence {
20
- func f< QS : Sequence where QS. Iterator. Element == Self . Iterator . Element > ( x: QS )
38
+ protocol Q : MySequence {
39
+ func f< QS : MySequence where QS. Iterator. Element == Self . Iterator . Element > ( x: QS )
21
40
}
22
41
23
- struct No < NT> : IteratorProtocol {
42
+ struct No < NT> : MyIteratorProtocol {
24
43
func next( ) -> NT ? {
25
44
return . none
26
45
}
@@ -29,7 +48,7 @@ struct No<NT> : IteratorProtocol {
29
48
class X < XT> : Q {
30
49
typealias Iterator = No < XT >
31
50
32
- func f< SX : Sequence where SX. Iterator. Element == X . Iterator . Element > ( x: SX ) {
51
+ func f< SX : MySequence where SX. Iterator. Element == X . Iterator . Element > ( x: SX ) {
33
52
}
34
53
35
54
func makeIterator( ) -> No < XT > {
0 commit comments