Files
swift-mirror/test/Concurrency/async_sequence_flatmap_overloading.swift
Doug Gregor 4c990dc0b9 Introduce an egregious source-compatibility hack for AsyncSequence.flatMap
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.
2024-01-25 16:04:58 -08:00

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
}