-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Reimplement actor isolation checking for referencing a declaration. #42229
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 |
|
||
bool ActorIsolation::isDistributedActor() const { | ||
return getKind() == ActorInstance && getActor()->isDistributedActor(); | ||
} |
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.
❤️
Optional<ReferencedActor> actorInstance = None); | ||
|
||
operator Kind() const { return kind; } | ||
}; |
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 entire way to model it is excellent, really looking forward to it 👍
89c7f65
to
7aadb7f
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@swift-ci please smoke test Linux |
1 similar comment
@swift-ci please smoke test Linux |
Start collapsing the several implementations of actor isolation checking into a single place that determines what it means to reference a declaration from a given context, potentially supplying an instance for an actor. This is partly cleanup, and partly staging for the implementation of the Sendable restrictions introduced in SE-0338. The result of this check falls into one of three categories: * Reference occurs within the same concurrency domain (actor/task) * Reference leaves an actor context to a nonisolated context (SE-0338) * Reference enters the context of the actor, which might require a combination of implicit async, implicit throws, and a "distributed" check. Throughout this change I've sought to maintain the existing semantics, even where I believe they are incorrect. The changes to the test cases are not semantic changes, but reflect the unification of some diagnostic paths that changed the diagnostic text but not when or how those diagnostics are produced. Additionally, SE-0338 has not yet been implemented, although this refactoring makes it easier to implement SE-0338. Use this new actor isolation checking scheme to implement the most common actor-isolation check, which occurs when accessing a member of an instance.
4235957
to
58382a8
Compare
@swift-ci please smoke test |
Rather than write an appoximation of the "is distributed thunk" check within the type checker, use the new actor reference checking logic with a referenced actor that is synthesized from the information in the constraint system.
…logic. Reimplement the final client of ActorIsolationRestriction, conformance isolation checking, to base it on the new "actor reference" logic. Centralize the diagnostics emission so we have a single place where we emit the primary diagnostic (which is heavily customized based on actor isolation/distributed/etc.) and any relevant notes to make adjustments to the witness and/or requirement, e.g., adding 'distributed', 'async', 'throws', etc. Improve the diagnostics slightly by providing Fix-Its when suggesting that we add "async" and/or "throws". With the last client of ActorIsolationRestriction gone, remove it entirely.
@swift-ci please smoke test |
return false; | ||
|
||
case ActorReferenceResult::EntersActor: | ||
return refResult.options.contains(ActorReferenceResult::Flags::Distributed); | ||
} | ||
} |
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 is awesome, thanks for centralizing all the logic 🥳
Start collapsing the several implementations of actor isolation checking
into a single place that determines what it means to reference a declaration
from a given context, potentially supplying an instance for an actor. This
is partly cleanup, and partly staging for the implementation of the
Sendable restrictions introduced in SE-0338. The result of this check
falls into one of three categories:
combination of implicit async, implicit throws, and a "distributed" check.
Throughout this change I've sought to maintain the existing semantics,
even where I believe they are incorrect. The changes to the test cases
are not semantic changes, but reflect the unification of some
diagnostic paths that changed the diagnostic text but not when or how
those diagnostics are produced. Additionally, SE-0338 has not yet been
implemented, although this refactoring makes it easier to implement
SE-0338.
Use this new actor isolation checking scheme to implement the most
common actor-isolation checks for accessing both member and
non-member declarations from expressions.