Conversation
Contributor
Author
|
@swift-ci please smoke test |
Permit the operation-closure return type `R` of `TaskLocal.withValue` to be noncopyable, matching the treatment already adopted by withTaskCancellationHandler, withDeadline, withSerialExecutor and withContinuation. ABI is preserved by treating the two kinds of overload differently: - The async `nonisolated(nonsending)` withValue and the internal withValueImpl are `@export(implementation)` (always emitted into the client, no exported symbol), so their return type is relaxed to `<R: ~Copyable>` in place; the async `@abi(...)` shadow is relaxed to match (it exists only to avoid a mangling collision with the legacy @_unsafeInheritExecutor declaration and emits no symbol either). - The synchronous withValue is `@inlinable` and has a real ABI symbol. A Copyable and a ~Copyable generic parameter have distinct calling conventions, so it cannot be relaxed in place. The public entry point becomes an `@export(implementation)` `withValue<R: ~Copyable>` (carrying the documentation); the original Copyable declaration is demoted to an internal `__abi_withValue` shim whose `@abi(...)` pins the original `withValue` mangling, so the existing ABI symbol keeps being emitted while the source name stays out of overload resolution (mirroring the existing __abi_get / get idiom in this file). The deprecated isolation:-taking overload and the _unsafeInheritExecutor_ / silgen_name shims remain copyable-only, preserving their frozen ABI. Noncopyable-return coverage (sync, async, throwing async) is added to test/Concurrency/Runtime/async_task_locals_basic.swift.
ktoso
force-pushed
the
wip-tasklocal-noncopyable
branch
from
September 23, 2026 03:37
4c73b75 to
9d35701
Compare
ktoso
commented
Sep 23, 2026
| // legacy @_unsafeInheritExecutor declaration. | ||
| @abi( | ||
| nonisolated(nonsending) func withValueNonisolatedNonsending<R>( | ||
| nonisolated(nonsending) func withValueNonisolatedNonsending<R: ~Copyable>( |
Contributor
Author
There was a problem hiding this comment.
This looks weird but is right; its an impl exported func so this isnt abi change
Contributor
Author
|
@swift-ci please smoke test |
ktoso
marked this pull request as draft
September 23, 2026 05:44
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow a ~Copyable return type to be used in
TaskLocal.withValue.