🍒[6.0][Concurrency] Reimplement @TaskLocal as a macro #73100
Merged
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.
Resolves rdar://120914014
Description: This reimplements @TaskLocal as a peer + accessor macro.
This is necessary to avoid sendable warnings about task locals having "mutable state" which property wrappers do introduce for the storage.
Scope/Impact: This removes mutable state errors from Swift 6.0 mode, without resorting to compiler hack to turn off the warning for this specific case.
Risk: There is one source compatibility edge case problem this has:
Previously, the compiler would have known that this property is an option, and default it to
nil. Now, users have to default it explicitly. We make efforts to not break the usual scenario of people declaring a task local withOptional<T>orT?types -- by parsing string types and trying to check for this. This is the best we can do here with macros.Testing: CI testing
Reviewed by: @hborla
Original PR: #73078
Radar: rdar://120914014