mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
36 lines
773 B
Swift
36 lines
773 B
Swift
// RUN: not %target-swift-frontend %s -typecheck
|
|
|
|
protocol MyIteratorProtocol {
|
|
typealias Element
|
|
mutating func next() -> Element?
|
|
}
|
|
|
|
protocol MySequence {
|
|
typealias Iterator : MyIteratorProtocol
|
|
func makeIterator() -> Iterator
|
|
}
|
|
|
|
protocol MyCollectionDefaults : MySequence {}
|
|
extension MyCollectionDefaults {
|
|
final func makeIterator() -> DefaultIterator<Self> {
|
|
return DefaultIterator()
|
|
}
|
|
}
|
|
|
|
protocol MyCollection
|
|
: MySequence, MyCollectionDefaults {}
|
|
|
|
struct DefaultIterator<C : MyCollectionDefaults> : MyIteratorProtocol {
|
|
mutating func next() -> C.Iterator.Element {
|
|
fatalError("")
|
|
}
|
|
}
|
|
|
|
struct FooIteratorWrapper<Base : MyIteratorProtocol> {
|
|
init(_ base: Base) {}
|
|
}
|
|
|
|
func f<C : MyCollection>(c: C) {
|
|
FooIteratorWrapper(c.makeIterator())
|
|
}
|