-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SE-0313] Implement type system, ABI, and runtime support for isolated parameters #37794
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci please test |
ce5131a
to
cc05833
Compare
@swift-ci please test |
Build failed |
…ated'. The notion of "actor-isolated" currently exists at the declaration level. For functions, it is going to be captured in the function type itself, where 'self' is declared to be 'isolated'. Model isolation both ways: the 'self' of a method that is isolated to an actor instance will be 'isolated' as well. We are still using declaration-based checking of actor isolation. However, by mirroring this information we can move more incrementally over to doing checking based on 'isolated' parameters.
With isolated parameters being part of a function's type, check to ensure that isolated and non-isolated parameters aren't incorrectly matched. Specifically, it is okay to add `isolated` to a parameter when there is a subtyping relationship, but not remove it: ```swift actor A { } func f(_: isolated A) { } func g(_: A) { } func test() { let _: (isolated A) -> Void = g // okay to add 'isolated' let _: (A) -> Void = f // error when removing 'isolated' } ```
…ers. Isolated parameters are part of function types. Encode them in function type manglings and metadata, and ensure that they round-trip through the various mangling and metadata facilities. This nails down the ABI for isolated parameters.
Rework the checking of actor member access to rely on "isolated" parameters (and captures thereof) to determine whether one can synchronously access an actor or not. This allows synchronous access via an "isolated" parameter as a general notion, which subsumes the declaration-based "self" access. Simplify the checking of and diagnostic reporting for actor member access by collapsing a number of redundant diagnostics down into a single, parameterized diagnostic with a single point of emission. This normalizes the logic a bit.
979fd23
to
5bcd5a8
Compare
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please smoke test |
@swift-ci please smoke test Linux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implement core support for
isolated
parameters:isolated
on parameters and ensuring that said parameters are of actor typeisolated
as a parameter modifier in the type systemself
parameter of actor-isolated methods beisolated
, unless they are explicitly marked asnonisolated
(MyActor) -> Void
functions to(isolated MyActor) -> Void
but not vice-versaisolated
parameter and update the various demangler/remangler pathsisolated
gets into function type metadata and round-trips through runtime type demangling and reflectionImplements the majority of rdar://75389492