when an expression that would be validly considered implicitly-async appears
within a sync context, we try to be a bit more specific about the problem
being that it's a sync context.
Property wrappers can provide global actor isolation based on the
property wrapper type itself (which affects the backing property),
`wrappedValue` (which affects the wrapped property), and
`projectedValue` (which affects the $ property). This allows us to
express, e.g., property wrappers that require accesses to occur on a
particular global actor.
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.
Allow us to tag declarations that are meant to be in a global actor, but
for which we don't yet want to enforce everything. This will be used for
better staging-in of global actor annotations, but for now it's a fancy
way to document @actorIndependent(unsafe).
Stages in the syntax for rdar://74241687 without really implementing it.
This patch updates the `actor class` spelling to `actor` in almost all
of the tests. There are places where I verify that we sanely handle
`actor` as an attribute though. These include:
- test/decl/class/actor/basic.swift
- test/decl/protocol/special/Actor.swift
- test/SourceKit/CursorInfo/cursor_info_concurrency.swift
- test/attr/attr_objc_async.swift
- test/ModuleInterface/actor_protocol.swift
`@asyncHandler` methods can override with a completely different actor
isolation because they will hop to the appropriate actor themselves.
Therefore, allow differing actor isolation when an `@asyncHandler`
method overrides another method, and don't propagate the actor
isolation from the overridden method to the overriding `@asyncHandler`
method.
Infer actor isolation from the overridden declaration unless some other
isolation attribute was explicitly specified directly on that
declaration. This allows type- and extension-level annotations with
a global actor to not break overrides.
Currently, we don't have a fix-it to insert 'async', so I've marked those places
as not expecting a fix-it, until someone goes and implements that (rdar://72313654)
Non-actor isolated synchronous functions were previously
allowed to call & reference global-actor isolated declarations.
This patch puts a stop to that.
Resolves rdar://71548470
Subclasses inherit the global actor from their superclass by default,
but it's okay to change it---it's just a default that can be
overridden on a per-member basis anyway.
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.
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