-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Implement #isolation
macro to produce the isolation of the current context
#70902
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
Conversation
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great first step 🥳
lib/Sema/CSSyntacticElement.cpp.rej
Outdated
@@ -0,0 +1,11 @@ | |||
@@ -1053,8 +1060,8 @@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to commit this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, sorry. My local tree is a mess. This PR needs a bit of work still
…context Introduce a new expression macro that produces an value of type `(any AnyActor)?` that describes the current actor isolation. This isolation will be `nil` in non-isolated code, and refer to either the actor instance of shared global actor in other cases. This is currently behind the experimental feature flag OptionalIsolatedParameters.
b438e25
to
255009d
Compare
Already tested, and I only dropped the one file. Merging... |
/// isolated, or `nil` if the code is nonisolated. | ||
@available(SwiftStdlib 5.1, *) | ||
@freestanding(expression) | ||
public macro isolation() -> (any AnyActor)? = Builtin.IsolationMacro |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just broke the Android community CI, which doesn't have a prebuilt host Swift compiler so the trunk compiler it builds doesn't use the swift-syntax parser and doesn't support macros:
swift/stdlib/public/Concurrency/Actor.swift:80:14: error: macros are not supported in this compiler
public macro isolation() -> (any AnyActor)? = Builtin.IsolationMacro
^
Other uses of macros in the stdlib have put in checks to avoid this problem, maybe something similar would work here?
Introduce a new expression macro that produces an value of type
(any AnyActor)?
that describes the current actor isolation. This isolation will benil
in non-isolated code, and refer to either the actor instance of shared global actor in other cases.This is currently behind the experimental feature flag OptionalIsolatedParameters.