Files
swift-mirror/test/Generics/rdar94848868.swift
Slava Pestov cd5ecbee16 Sema: Implement missing part of SE-0346
The proposal states that this should work, but this was never
implemented:

    protocol P<A> {
      associatedtype A
    }

    struct S: P<Int> {}

- Fixes https://github.com/swiftlang/swift/issues/62906.
- Fixes rdar://91842338.
2025-06-03 17:28:19 -04:00

26 lines
784 B
Swift

// RUN: %target-typecheck-verify-swift
// This is too circular to work, but it shouldn't crash.
protocol MyCollectionProtocol: Collection where Iterator == MyCollectionIterator<Self> {}
// expected-error@-1 {{circular reference}}
struct MyCollectionIterator<MyCollection: MyCollectionProtocol>: IteratorProtocol {
// expected-note@-1 3{{through reference here}}
mutating func next() -> MyCollection.Element? {
return nil
}
}
struct MyCollection: MyCollectionProtocol {
struct Element {}
var startIndex: Int { fatalError() }
var endIndex: Int { fatalError() }
func index(after i: Int) -> Int { fatalError() }
subscript(position: Int) -> Element { fatalError() }
public func makeIterator() -> MyCollectionIterator<Self> { fatalError() }
}