Skip to content

Enforce safe access to unsafe global actor declarations only from "new" code #36266

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 3 commits into from
Mar 4, 2021

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 4, 2021

Allow references to unsafe global actor-isolated declarations only from
existing code that has not adopted concurrency features (such as
async, @Concurrent closures, etc.). This allows declarations that
should be isolated to a global actor to be annotated as such without
breaking existing code (as if isolation was unspecified), while code
that does adopt concurrency will treat the declaration as being part
of that global actor.

rdar://74241687

With "unsafe" global actor isolation, we only enforce actor isolation
when interacting with other explicitly-isolated code. This allows some
code to be annotated with, e.g., `@MainActor(unsafe)` so that users
who opt into concurrency get proper diagnostics, but existing code
does not change.
Whether it's a cross-actor reference is better modeled as a separate
axis rather than part of the "kind". All of the clients were treating it
this was already.
…w" code.

Allow references to unsafe global actor-isolated declarations only from
existing code that has not adopted concurrency features (such as
async, @Concurrent closures, etc.). This allows declarations that
should be isolated to a global actor to be annotated as such without
breaking existing code (as if isolation was unspecified), while code
that does adopt concurrency will treat the declaration as being part
of that global actor.
@DougGregor DougGregor changed the title @DougGregor Enforce safe access to unsafe global actor declarations only from "new" code Enforce safe access to unsafe global actor declarations only from "new" code Mar 4, 2021
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test macOS

@DougGregor
Copy link
Member Author

Linux failure was unrelated. Trying again...

@DougGregor
Copy link
Member Author

@swift-ci please smoke test Linux

@DougGregor DougGregor merged commit 093a6dd into swiftlang:main Mar 4, 2021
@DougGregor DougGregor deleted the global-actor-unsafe branch March 4, 2021 07:38
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.

1 participant