-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Global actor function type isolation #36907
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
Global actor function type isolation #36907
Conversation
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please smoke test |
@swift-ci please smoke test macOS |
@swift-ci please test and merge |
8846bc3
to
57e7f6b
Compare
@swift-ci please test |
Build failed |
Build failed |
…qualified type. When referencing a function that is on a global actor, e.g., @mainactor func doSomething() -> Int the result of that reference is a global-actor-qualified function type, e.g., @mainactor () -> Int Part of rdar://76030136.
…references Check actor isolation of calls to functions with global-actor-qualified type. This closes a pre-existing loophole where a value of global-actor-qualified function type could be called from any context. Paired with this, references to global-actor-qualified function declarations will get global-actor-qualified function type whenever they are referenced within an experience, i.e., whenever we form a value of that type. Such references can occur anywhere (one does not need to be on the actor), and carrying the global actor along with the function type ensures that they can only be called from the right actor. For example: @mainactor func onlyOnMainActor() { ... } func callIt(_ fn: @mainactor () -> Void) { fn() // error: not on the main actor, so cannot synchronously call // this wasn't previously diagnosed } func passIt() { callIt(onlyOnMainActor) // okay to pass the function // used to be an error } While here, fix up some broken substitution logic for global-actor-qualified function types and "override" actor isolation.
We don't want the debugger stepping into these.
57e7f6b
to
3dc65c6
Compare
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Windows CI failed with "There is not enough space on the disk.". Restarting |
@swift-ci please test Windows |
Build failed |
@swift-ci please test macOS |
@swift-ci please test macOS |
Updates to async codegen, possibly from swiftlang/swift#36907, have changed the execution flow in this test. The fix is to be more liberal with the step-avoid- setting. Also the number of stops has changed in my local testing, and so the assertion has been weakened to check that it stops greater than zero times, which is enough to verify that the test is actually stopping. A follow up is to understand why it changed locally for me. rdar://76833116
Updates to async codegen, possibly from swiftlang/swift#36907, have changed the execution flow in this test. The fix is to be more liberal with the step-avoid- setting. Also the number of stops has changed in my local testing, and so the assertion has been weakened to check that it stops greater than zero times, which is enough to verify that the test is actually stopping. A follow up is to understand why it changed locally for me. rdar://76833116 (cherry picked from commit bb79c2b)
Updates to async codegen, possibly from swiftlang/swift#36907, have changed the execution flow in this test. The fix is to be more liberal with the step-avoid- setting. Also the number of stops has changed in my local testing, and so the assertion has been weakened to check that it stops greater than zero times, which is enough to verify that the test is actually stopping. A follow up is to understand why it changed locally for me. rdar://76833116 (cherry picked from commit 8f520b5)
When referencing a function that is on a global actor, e.g.,
the result of that reference is a global-actor-qualified function type, e.g.,
Check actor isolation of calls to functions with global-actor-qualified
type. This closes a pre-existing loophole where a value of
global-actor-qualified function type could be called from any context.
Paired with this, references to global-actor-qualified function
declarations will get global-actor-qualified function type whenever
they are referenced within an experience, i.e., whenever we form a
value of that type. Such references can occur anywhere (one does not
need to be on the actor), and carrying the global actor along with the
function type ensures that they can only be called from the right
actor. For example:
Fixes most of what is covered by rdar://76030136.