Skip to content

Commit afbe114

Browse files
committed
Make test/Constraints/associated_self_types.swift self-contained
1 parent be3bf99 commit afbe114

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

test/Constraints/associated_self_types.swift

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
11
// RUN: %target-parse-verify-swift
22

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 {
417
init()
518
}
619
postfix operator ~>> {}
720

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 {
922
return A()
1023
}
1124

12-
protocol _ExtendedSequence : Sequence {
25+
protocol _ExtendedSequence : MySequence {
1326
postfix func ~>> <A : P where Self.Iterator.Element == A.Iterator.Element>(s: Self) -> A
1427
}
1528

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>
1736
}
1837

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)
2140
}
2241

23-
struct No<NT> : IteratorProtocol {
42+
struct No<NT> : MyIteratorProtocol {
2443
func next() -> NT? {
2544
return .none
2645
}
@@ -29,7 +48,7 @@ struct No<NT> : IteratorProtocol {
2948
class X<XT> : Q {
3049
typealias Iterator = No<XT>
3150

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) {
3352
}
3453

3554
func makeIterator() -> No<XT> {

0 commit comments

Comments
 (0)