Hello Swift community,
As the language has made additional progress towards the Swift 6 milestone, the Language Steering Group has been evaluating what the migration to the Swift 6 language mode is expected to look like for a variety of projects. As a result of this evaluation, the the Language Steering Group has decided that the upcoming feature flag InternalImportsByDefault
declared by SE-0409 will no longer be enabled by default in Swift 6 mode.
The practical consequences of this decision are that in Swift 6 mode the default access level for import
statements will remain public
, just as in Swift 5. The InternalImportsByDefault
flag will be enabled in a future, post-Swift-6 language mode. Explicit use of access control keywords on import statements, such as internal import
, will be fully supported in Swift 6, and users who wish to proactively make use of the feature will of course still be able to do so: this is only a deferral of the source-breaking aspects of the proposal. Projects which explicitly write public import
for all publicly-used imports will have an easier migration path for the future language version which enables InternalImportsByDefault
.
The Language Steering Group's decision was based on a few factors:
- With the realities of the the Swift 6 migration taking place, one emergent piece of information has been that in many cases, a substantial amount of the changes required come from changing the default access level of import statements as described in SE-0409. Moreover, since there has not been (and will not be) a Swift release which supports the changes in SE-0409 before the release of Swift 6.0, authors of library code (the primary demographic affected by this source break) who wish to support the Swift 6 language mode while also continuing to support compilation by older compilers would need to do a complex
#if
dance around a large number of import statements. - As announced previously, the Language Steering Group has narrowed the focus of the Swift 6 language mode to enabling data-race safety by default. While this proposal (and the associated source break) were accepted before that announcement, the Group believes that had the timing on this proposal been marginally different, i.e., had it been reviewed after the focus of Swift 6 had been narrowed, the source break proposed by SE-0409 would not have been accepted for Swift 6.
- More implementation work is needed for the compiler to be able to take advantage of optimizations available for modules which are imported at most internally throughout an entire client module, so the benefit of flipping the switch now is relatively small compared to the large amount of source churn it would cause.
As always, thank you to everyone for your feedback and for helping make Swift a better language.