-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce an egregious source-compatibility hack for `AsyncSequence.f…
…latMap` 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.
- Loading branch information
1 parent
a3ae340
commit 4c990dc
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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 | ||
} |