Since the last update laying out the design priorities for the Swift 6 language mode, the project has been making steady advances towards this next milestone. However, some of the previously stated goals include open-ended research questions that are still in the early stages of development. Instead of holding up Swift 6 as this work progresses, the Language Steering Group is narrowing the focus of remaining changes for Swift 6 to data-race safety by default.
Readiness of data-race safety by default
There are still a number of bugs and holes in the Sendable checking model that admit data races under strict concurrency checking. Equally important, strict concurrency checking currently issues a significant number of false positive reports of data races, making the complete checking difficult to program against.
The Swift 6 language mode will only be declared ready once the Language Steering Group determines that the programming model is effective and usable. The remaining language work to complete data-race safety for the Swift 6 language mode will fall into two categories:
- Fill all holes in the strict concurrency model so that data races are diagnosed statically, or dynamically where static safety cannot be proven.
- Mitigate false reports of data races on patterns that are proven to be safe.
Swift 5.10 contains a number of significant bug fixes in the actor isolation and Sendable checking. In addition, the following language changes are currently being designed and implemented to undergo the Swift evolution review process:
- SE-0411: Isolated default value expressions
- Inferring
@Sendable
for methods and key-path literals - Strict concurrency checking for global and static variables
- Improved control over closure actor isolation
- Lifting restrictions on non-
Sendable
values through isolated value regions
Together, these changes fill the remaining major holes in strict concurrency checking and improve the usability of strict concurrency checking by introducing more Sendable
inference and enabling safe ways to transfer non-Sendable
values across isolation boundaries. The Language Steering Group acknowledges that other language changes in the area of concurrency are important, but the changes above are necessary for defining the Swift 6 language mode. Other concurrency features are additive and can be explored independently.
The Swift 6 migration
Upcoming features are critical for migrating to the Swift 6 language mode: one can enable individual upcoming features one at a time to incrementally move a code base toward Swift 6, before adopting the full language mode. There are a number of previously-accepted upcoming features that will be enabled by default in Swift 6:
- SE-0274: Concise magic file names (
ConciseMagicFile
) - SE-0286: Forward-scan matching for trailing closures (
ForwardTrailingClosures
) - SE-0337: Incremental migration to concurrency checking (
StrictConcurrency
) - SE-0354: Regex Literals (
BareSlashRegexLiterals
) - SE-0383: Deprecate @UIApplicationMain and @NSApplicationMain (
DeprecateApplicationMain
) - SE-0384: Importing Forward Declared Objective-C Interfaces and Protocols (
ImportObjcForwardDeclarations
) - SE-0401: Remove Actor Isolation Inference caused by Property Wrappers (
DisableOutwardActorInference
) - SE-0409: Access-level modifiers on import declarations (
InternalImportsByDefault
)
The Language Steering Group has decided that one previously-accepted upcoming feature, ExistentialAny
, will not be enabled by default in Swift 6. SE-0335: Introduce existential any
introduces the any
keyword to identify existential types. The proposal also specifies that "bare" protocol names will no longer be permitted as types---they must either use any
or some
, as appropriate---under the upcoming feature flag ExistentialAny
. Given the concerns about migration to consistent use of existential any
in the language, and the expectation that additional language improvements will be coming that might affect the end result of that migration, the Language Steering Group is deferring the source-incompatible changes in SE-0335 to a future language revision.
Additional evolution proposals may include source-incompatible changes for Swift 6, and the Language Steering Group will evaluate such proposals on a case-by-case basis for high value to the language relative to the cost of source incompatibilities. For example, sufficiently high value changes might include minor type inference changes that are necessary for completing a major feature, such as typed throws, or semantic changes in pursuit of data race safety.
Once all of the upcoming features for Swift 6 are in place, the Language Steering Group will provide a migration guide that suggests an optimal path for incrementally enabling strict concurrency checking in a project, along with practical guidance on how to address certain kinds of strict concurrency violations in common code patterns. Community feedback on these guides will be critical to evaluating the approachability of the Swift 6 migration.