The initializer DeclContext is not a ValueDecl; instead, fish out the
associated VarDecl using other means.
Also while I'm here, fix actor isolation checking in the case where
'self' is explicitly captured in a capture list as well.
Fixes <rdar://problem/72727986>.
[broken] first impl of @actorIndependent in the type checker.
[broken] fixed mistake in my parsing code wrt invalid source range
[broken] found another spot where ActorIndependent needs custom handling
[broken] incomplete set of @actorIndependent(unsafe) tests
updates to ActorIndependentUnsafe
[fixed] add FIXME plus simple handling of IndependentUnsafe context
finished @actorIndependent(unsafe) regression tests
added wip serialization / deserialization test
focus test to just one actor class
round-trip serialize/deserialize test for @actorIndependent
serialize -> deserialize -> serialize -> compare to original
most of doug's comments
addressed robert's comments
fix printing bug; add module printing to regression test
[nfc] update comment for ActorIsolation::IndependentUnsafe
Both overriding declarations and subclasses must have the actor
isolation as their overridden declarations or superclasses,
respectively. Enforce this, ensuring that we're also doing the
appropriate substitutions.
ActorIsolation is rendered as a descriptive phrase before an entity,
e.g, "actor-independent" or "global actor 'UIActor'-isolated" when
used in diagnostics.
Implement propagation rules for global actor constraints, which can come from:
* Enclosing extension or type
* Superclass of a class
* Overridden declaration
* Requirement witnessed by a declaration
* Storage declaration for an accessor
The "privileged" cases for actor instance and global actor isolation
covered the case where the entity itself is within the particular
actor but can be freely used from outside the actor, e.g., because it
is asynchronous or an asynchronous handler. This is the wrong modeling
for the problem, because it's only the first part of that---what the
isolation of the particular entity is---that is needed for most
clients. There will be a different abstraction for that.
Extend the actor isolation checking rules to account for global
actors. For example, a function annotated with a given global actor
can invoke synchronous methods from the same global actor, but not
from a different global actor or a particular actor instance.
Similarly, a method of an (instance) actor that is annotated with a
global actor attribute is not part of the (instance) actor and,
therefore, cannot operate on its actor-isolated state.
Introduce a new attribute `@actorIndependent` that specifies that a
given declaration is considered to be independent of any actor.
Actor-independent declarations do not have access to actor-isolated
state, even when they are declared as instance members of the actor.
On the other hand, actor-independent declarations can be used to
conform to (synchronous) requirements in protocols.