Reimplement actor isolation checking for referencing a declaration.

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.
This commit is contained in:
Doug Gregor
2022-04-06 14:57:25 -07:00
parent cf2e90bbd2
commit eef2704c86
11 changed files with 866 additions and 521 deletions

View File

@@ -9380,3 +9380,7 @@ void swift::simple_display(llvm::raw_ostream &out, AnyFunctionRef fn) {
else
out << "closure";
}
bool ActorIsolation::isDistributedActor() const {
return getKind() == ActorInstance && getActor()->isDistributedActor();
}