Skip to content

Frontend: Allow -enable-experimental-feature to specify upcoming features #75962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Aug 19, 2024

During the lifecycle of a feature, it may start as an experimental feature and then graduate to become an upcoming feature. To preserve compatibility with projects that adopted the feature when it was experimental, -enable-experimental-feature ought to be able to enable upcoming features, too.

Since projects may use -enable-experimental-feature for compatibility with an older toolchain that does not have the feature as an upcoming feature, there is no warning when the flag is used to enable an upcoming feature.

Note that if the semantics of a feature change when it graduates from experimental to upcoming, then the feature must be renamed so that projects using the experimental feature have an opportunity opt-in to the new semantics of the upcoming feature.

Resolves rdar://134276783.

@tshortli tshortli requested a review from DougGregor August 19, 2024 19:20
@tshortli tshortli force-pushed the experimental-upcoming-features branch 2 times, most recently from 5e7e2d1 to c015c95 Compare August 19, 2024 21:26
@tshortli tshortli requested a review from ktoso as a code owner August 19, 2024 21:26
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! We had a few Issues were people used InferSendableFromCaptures as experimental feature and once we promoted it, that stopped working.

Have you considered adding a warning for this case to nudge people towards use of upcoming instead of keeping it on experimental?

@tshortli
Copy link
Contributor Author

Have you considered adding a warning for this case to nudge people towards use of upcoming instead of keeping it on experimental?

I considered but rejected that idea because I don't want to create a situation where a project owner has an un-addressable warning if they need to support older toolchains that only support the feature as experimental.

@xedin
Copy link
Contributor

xedin commented Aug 19, 2024

if they need to support older toolchains that only support the feature as experimental.

I see, sounds good!

tshortli added a commit to tshortli/swift-package-manager that referenced this pull request Aug 20, 2024
…mportsByDefault`.

Both the `StrictConcurrency` and `InternalImportsByDefault` features became
"upcoming" features instead of "experimental" features in the Swift 6 compiler.
This means that specifying those features with `.enableExperimentalFeature()`
no longer works, and therefore these settings in SwiftPM's Package.swift have
become inactive. I'm making the compiler more lenient, so that
`-enable-experimental-feature` will enable the corresponding upcoming feature
if relevant (swiftlang/swift#75962) but in the meantime
it appears that some of the code in SwiftPM needs some fixes to continue to be
accepted by the compiler with these features on.

Additionally, I've removed explicit enablement of `AccessLevelOnImports` since
that feature became standard in the Swift 5.10 compiler.
@tshortli
Copy link
Contributor Author

Blocked by swiftlang/swift-package-manager#7895.

tshortli added a commit to tshortli/swift-package-manager that referenced this pull request Aug 20, 2024
Both the `StrictConcurrency` and `InternalImportsByDefault` features became
"upcoming" features instead of "experimental" features in the Swift 6 compiler.
This means that specifying those features with `.enableExperimentalFeature()`
no longer works with newer toolchains, and therefore these settings in
SwiftPM's Package.swift have become inactive. I'm making the compiler more
lenient, so that `-enable-experimental-feature` will enable the corresponding
upcoming feature if relevant (swiftlang/swift#75962)
but in the meantime it appears that some of the code in SwiftPM needs some
fixes to continue to be accepted by the compiler with these features on.
tshortli added a commit to swiftlang/swift-package-manager that referenced this pull request Aug 20, 2024
Address some `InternalImportsByDefault` diagnostics in the
`_AsyncFileSystem` which have crept in because the Swift 6 toolchain
isn't enforcing
`.enableExperimentalFeature("InternalImportsByDefault")`.

### Motivation:

Both the `StrictConcurrency` and `InternalImportsByDefault` features
became "upcoming" features instead of "experimental" features in the
Swift 6 compiler. This means that specifying those features with
`.enableExperimentalFeature()` no longer works with newer toolchains,
and therefore these settings in SwiftPM's `Package.swift` have become
inactive. I'm making the compiler more lenient, so that
`-enable-experimental-feature` will enable the corresponding upcoming
feature if relevant (swiftlang/swift#75962) but
in the meantime it appears that some of the code in SwiftPM needs some
fixes to continue to be accepted by the compiler with these features on.


### Modifications:

Adjusted access level on a number of import statements in files
belonging to the `_AsyncFileSystem` target.

### Result:

`_AsyncFileSystem` builds successfully when `InternalImportsByDefault`
is actually enabled with the Swift 6 toolchain.
…ures.

During the lifecycle of a feature, it may start as an experimental feature and
then graduate to become an upcoming feature. To preserve compatibility with
projects that adopted the feature when it was experimental,
`-enable-experimental-feature` ought to be able to enable upcoming features,
too.

Since projects may use `-enable-experimental-feature` for compatibility with an
older toolchain that does not have the feature as an upcoming feature, there is
no warning when the flag is used to enable an upcoming feature.

Note that if the semantics of a feature change when it graduates from
experimental to upcoming, then the feature must be renamed so that projects
using the experimental feature have an opportunity opt-in to the new semantics
of the upcoming feature.

Resolves rdar://134276783.
@tshortli tshortli force-pushed the experimental-upcoming-features branch from c015c95 to ad1acd7 Compare August 20, 2024 14:49
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli tshortli enabled auto-merge August 20, 2024 14:50
@tshortli tshortli disabled auto-merge August 21, 2024 21:33
@tshortli
Copy link
Contributor Author

swiftlang/swift-package-manager#7905

@swift-ci please smoke test

@tshortli tshortli merged commit 993becc into swiftlang:main Aug 22, 2024
3 checks passed
@tshortli tshortli deleted the experimental-upcoming-features branch August 22, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants