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.
`actor` is a standalone contextual keyword now and should
be treated as such, `actor class` is no longer allowed
and results in a parse error.
Resolves: rdar://75753598
1. Removes gating on -enable-experimental-concurrency.
2. Updates eff. prop tests to remove experimental flag,
and also adjusts some tests slightly to avoid things
that are still behind that flag.
Actor inheritance was removed in the second revision of SE-0306. Remove
the ability to inherit actors.
Note that this doesn't fully eliminate all vestigates of inheritance
from actors. There are simplifications that need to be performed
still, e.g., there's no need to distinguish
designated/convenience/required initializers. That will follow.
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
This patch cleans up how we emit the errors for disallowing the
properties and methods of an actor to be applied to the protocol
conformance. Rather than having multiple error messages for each case,
we keep one error message saying that the actor-isolated
method/variable/what-have-you cannot be used to satisfy a protocol
requirement, then allow multiple notes with fix-its to allow the
programmer to choose what they want to do. The notes have a better
description of what each option does.
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
Witnesses and requirements need to agree on their global actor
annotations. However, this is not true for 'async' or '@asyncHandler'
witnesses, for which it does not matter what the actor annotation is
because part of the contract is that the function will execute on the
appropriate actor.
With actor isolation checking for protocol witnesses moved out of the
witness-matching phase, move the corresponding diagnostics from notes
(that would have been on the "type does not conform" error) to
freestanding errors.
Rather than relying on clients to cope with the potential for circular
inheritance of superclass declarations, teach SuperclassDeclRequest to
establish whether circular inheritance has occurred and produce "null"
in such cases. This allows other clients to avoid having to think about
To benefit from this, have SuperclassTypeRequest evaluate
SuperclassDeclRequest first and, if null, produce a Type(). This
ensures that we don't get into an inconsistent situation where there
is a superclass type but no superclass declaration.
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.
Enforce the actor-isolation constraint that an actor-isolated member
(e.g., a non-async instance method or an instance property) cannot be
used to conform to a protocol requirement.
* [Sema] Factor out shouldAttemptInitializerSynthesis
This makes sure we don't attempt to synthesize
a memberwise or default initializer for an invalid
decl, or one in a module interface.
* [Sema] Requesify inheritsSuperclassInitializers
This commit introduces a request for computing
whether a class inherits both designated and
convenience initializers from its superclass.
The shared logic of finding initializers which the
subclass hasn't overriden has been factored out
into `collectNonOveriddenSuperclassInits`.
* Cleanup addImplicitInheritedConstructorsToClass
This commit removes some code that's no longer
needed. In addition, now that we've requestified
`inheritsSuperclassInitializers`, we can directly
diagnose on non-inherited required convenience
inits within the loop.
* Inherited init synthesis no longer deals with clang decls
Now that the computation of
`inheritsSuperclassInitializers` has been split off
into a request, we can avoid calling
`addImplicitInheritedConstructorsToClass` for clang
decls.
* Address review feedback
Continue to cache the InheritsSuperclassInits bit
on the AST.
This loop in the constraint solver won't terminate when given
ill-formed code involving circular inheritance. Make it
terminate. Fixes rdar://problem/54296278.
When a class has missing vtable entries, we don’t allow it to be subclassed. This is unnecessarily restrictive for resilient classes, and @_implementationOnly imports now make missing vtable entries much more common. This commit carves out an exception to that rule for resilient classes.
Fixes <rdar://problem/50902125>.
First, if the base parameter is inout or vararg, the derived parameter
must be too. Second, we do not allow covariant overrides of inout or
vararg parameters.
Fixes <https://bugs.swift.org/browse/SR-10231>.