mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Allow `AsyncSequence.flatMap` to be defined with "incorrect" availability, meaning that the function can refer to the `Failure` associated type in its where clause even though the function is back-deployed to before the `Failure` associated type was introduced. We believe this is safe, and that this notion can be generalized to any use of an associated type in a same-type constraint of a function (yes, it sounds weird), but for now introduce a narrower hack to see how things work in practice and whether it addresses all of the source-compatibility concerns we've uncovered.
22 lines
572 B
Swift
22 lines
572 B
Swift
// RUN: %target-swift-frontend -typecheck %s -verify
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
@available(SwiftStdlib 5.1, *)
|
|
struct MyAsyncSequence<Element>: AsyncSequence {
|
|
struct AsyncIterator: AsyncIteratorProtocol {
|
|
mutating func next() -> Element? { nil }
|
|
}
|
|
|
|
func makeAsyncIterator() -> AsyncIterator { .init() }
|
|
}
|
|
|
|
@available(SwiftStdlib 5.1, *)
|
|
func testMe(ms: MyAsyncSequence<String>) {
|
|
let flatMS = ms.flatMap { string in
|
|
return MyAsyncSequence<[Character]>()
|
|
}
|
|
|
|
let _: AsyncFlatMapSequence<MyAsyncSequence<String>, MyAsyncSequence<[Character]>> = flatMS
|
|
}
|