Skip to content

Add -enable-experimental-feature X for experimental features. #59113

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 7 commits into from
May 27, 2022

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented May 26, 2022

Introduce a simpler declarative approach to describing experimental features, where each feature has its own feature identifier (e.g., VariadicGenerics). The feature can be enabled with the -enable-experimental-feature FeatureName flag, and detected with #if $FeatureName. This metaprograms away the need to add new language options and compiler options each time we stage in a new experimental feature. Experimental features can only be enabled in non-production (+Asserts) builds.

Adopt this mechanism for a number of experimental features: variadic generics, static asserts, named opaque types, move-only, one-way closure parameters, and associated type witness inference via type witness systems.

Map the existing "experimental" flags over to the new system, but don't remove them just yet.

Experimental features can only be enabled in non-production (+Asserts)
builds. They can be detected with `hasFeature` in the same manner as
"future" features.

The `-enable-experimental-feature X` flag will also look for future
features by that name, so that when an experimental feature becomes an
accepted future feature, it will still be enabled in the same manner.

Switch variadic generics over to this approach, eliminating the
specific LangOption for it.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@zoecarver
Copy link
Contributor

Looking forward to applying this to interop too! Thanks for the patch :)

@DougGregor DougGregor merged commit 93fef05 into swiftlang:main May 27, 2022
@DougGregor DougGregor deleted the enable-experimental-feature branch May 27, 2022 22:07
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