I've got an all-new proposal to fix how actor initialization works, based on feedback from the first review. There are also changes to actor initializer delegation, stored property isolation, and deinitializers.
Since the proposal differs significantly from the first review, this is a pitch. Here's a very informal and incomplete summary of the major functionality proposed, along with some links into the document itself for more details:
- Actor initializers that are not isolated to the actor will now allow you to do anything you normally can from a
nonisolatedmethod. In exchange, Swift will automatically reject accesses to stored properties that might be unsafe. Here is the problem description and proposed solution.
- Deinitializers of an actor can no longer access non-sendable stored properties of the instance. Here is the problem description and proposed solution
- A type's stored property cannot have a default value if its isolation is not compatible with its initializers. Here is the problem description and proposed solution
conveniencekeyword is no longer required to define a delegating initializer of an actor. Here is the problem description and proposed rules for their delegating initializers, which is continued in the Sendability section.
The proposal is lengthy, but I've tried to always follow each discussion with an example, and have isolated the more esoteric discussions under "In-depth Discussion" headings at the end of some sections. As always, I greatly appreciate any time you spend helping to improve Swift by reading this proposal!