Skip to content

[stdlib] Generalize withContiguous[Mutable]StorageIfAvailable for typed throws#88534

Open
clintonpi wants to merge 1 commit intoswiftlang:mainfrom
clintonpi:with-contiguous-mutable-storage-if-available-typed-throws-generalization
Open

[stdlib] Generalize withContiguous[Mutable]StorageIfAvailable for typed throws#88534
clintonpi wants to merge 1 commit intoswiftlang:mainfrom
clintonpi:with-contiguous-mutable-storage-if-available-typed-throws-generalization

Conversation

@clintonpi
Copy link
Copy Markdown
Contributor

  • Adds new typed throws versions of withContiguousStorageIfAvailable and withContiguousMutableStorageIfAvailable as requirements for Sequence and MutableCollection protocols respectively.
  • Generalizes their concrete implementations.
  • The concrete implementations of these methods are now @_alwaysEmitIntoClient. This makes their concrete implementations less preferred witnesses, ranking their default implementations higher. Therefore, this PR also marks their default implementations as @_disfavoredOverload so their concrete implementations stay preferred.

@clintonpi clintonpi requested a review from a team as a code owner April 17, 2026 18:43
@clintonpi
Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@clintonpi
Copy link
Copy Markdown
Contributor Author

@swift-ci please test source compatibility

@clintonpi
Copy link
Copy Markdown
Contributor Author

@swift-ci please benchmark

#if hasFeature(Embedded)
return try base.withContiguousStorageIfAvailable(body)
#else // hasFeature(Embedded)
do {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we use do throws(E) here? So we don't have to force cast.

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