Skip to content

Reapply #87698 and fix overload resolution for Sequence+AsyncSequence types.#88442

Open
clintonpi wants to merge 2 commits intoswiftlang:mainfrom
clintonpi:async-sequence-typed-throws-generalization
Open

Reapply #87698 and fix overload resolution for Sequence+AsyncSequence types.#88442
clintonpi wants to merge 2 commits intoswiftlang:mainfrom
clintonpi:async-sequence-typed-throws-generalization

Conversation

@clintonpi
Copy link
Copy Markdown
Contributor

Since generalizing Sequence methods for typed throws, the overload resolution prefers the corresponding AsyncSequence methods which cannot be generalized yet. To fix this, all rethrowing Sequence methods (except withContiguousStorageIfAvailable) were duplicated in a new extension (extension AsyncSequence where Self: Sequence).

@clintonpi clintonpi requested a review from a team as a code owner April 13, 2026 15:59
@clintonpi
Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

@clintonpi
Copy link
Copy Markdown
Contributor Author

@swift-ci please test source compatibility

Since generalizing Sequence methods for typed throws, the overload resolution prefers the corresponding AsyncSequence methods which cannot be generalized yet. To fix this, all rethrowing Sequence methods (except withContiguousStorageIfAvailable) were duplicated in a new extension (`extension AsyncSequence where Self: Sequence`).
@clintonpi clintonpi force-pushed the async-sequence-typed-throws-generalization branch from fd496a6 to c3e2873 Compare April 13, 2026 16:37
@clintonpi
Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

@clintonpi
Copy link
Copy Markdown
Contributor Author

@swift-ci please test source compatibility

Copy link
Copy Markdown
Contributor

@phausler phausler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach looks good; what does it mean for when we do further typed throws support for async sequence?

@clintonpi
Copy link
Copy Markdown
Contributor Author

If the support is back-deployed covering SwiftStdlib 5.1, then these duplicates can be safely deleted with no source breakage. Else, they'll have to stay in place and be annotated as obsolete.

@clintonpi
Copy link
Copy Markdown
Contributor Author

Also, if the duplicates were somehow forgotten and co-exist with the future AsyncSequence typed-throwing methods, other things being equal, the future typed-throwing ones will be picked where the current rethrowing ones are picked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants