Skip to content

🍒[6.0][Concurrency] Reimplement @TaskLocal as a macro #73100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2024

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Apr 18, 2024

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:

  • because macros don't have type information, we cannot handle this situation:
typealias MyOptionInt = Int?
@TaskLocal static var example: MyOptionInt

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 with Optional<T> or T? 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

@ktoso ktoso requested a review from a team as a code owner April 18, 2024 09:50
@ktoso ktoso force-pushed the pick-wip-tasklocal-macro branch from 1a13dcd to 7e569ac Compare April 19, 2024 04:47
@ktoso
Copy link
Contributor Author

ktoso commented Apr 19, 2024

@swift-ci please test

@ktoso ktoso force-pushed the pick-wip-tasklocal-macro branch from 7e569ac to 1fd8a14 Compare April 30, 2024 04:54
@ktoso
Copy link
Contributor Author

ktoso commented Apr 30, 2024

@swift-ci please test

@ktoso
Copy link
Contributor Author

ktoso commented Apr 30, 2024

@swift-ci please test

@ktoso ktoso enabled auto-merge (squash) April 30, 2024 07:27
@ktoso
Copy link
Contributor Author

ktoso commented May 2, 2024

swiftlang/swift-driver#1592
@swift-ci please test

@ktoso ktoso merged commit d52623e into swiftlang:release/6.0 May 2, 2024
@ktoso ktoso deleted the pick-wip-tasklocal-macro branch May 2, 2024 07:24
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