Skip to content
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

Enable experimental on language imports #19760

Conversation

nicolasstucki
Copy link
Contributor

Make it easier to use experimental language features out of the box. We already have -experimental that enables experimental mode globally by adding the @experimental annotation to all top-level definitions. The complication was that this flag was necessary to use experimental language features. It was not always easy to set (for example in the REPL) and it is all or nothing. Users can also annotate explicitly all top-level definitions that use language features with @experimental.

Now, the import of an experimental language feature will automatically enable experimental mode. If the import is at the top-level, all definitions in the file are experimental. If the import is local only the top-level definition containing the import will be marked as experimental.

Some experimental features might not need the experimental mode.

@nicolasstucki nicolasstucki self-assigned this Feb 22, 2024
@nicolasstucki nicolasstucki force-pushed the enable-experimental-on-language-imports branch 2 times, most recently from 6f93f72 to 14dae56 Compare February 23, 2024 07:49
The `@experimental` flag is added to definitions in the scope where
the the experimental language feature is imported.
@nicolasstucki nicolasstucki force-pushed the enable-experimental-on-language-imports branch from 5d1624b to 2a1a72c Compare February 23, 2024 09:35
@nicolasstucki nicolasstucki added the needs-minor-release This PR cannot be merged until the next minor release label Feb 23, 2024
@nicolasstucki nicolasstucki force-pushed the enable-experimental-on-language-imports branch 2 times, most recently from 01089a1 to 21407ce Compare February 26, 2024 12:16
@nicolasstucki nicolasstucki force-pushed the enable-experimental-on-language-imports branch from 21407ce to d35ec2a Compare February 26, 2024 15:39
nicolasstucki added a commit that referenced this pull request Feb 29, 2024
Add explicitly `-experimental -Yno-experimental` to tests that use
definitions that are `@experimental` in the standard library.
`-Yno-experimental` disables the experimental mode from nightly builds
and `-experimental` adds `@experimental` to all top-level definitions.

This is in preparation of #19760 and the disabling of experimental mode
by default in nightly builds. When nighly experimental mode will be
disabled we will be able to drop the `-Yno-experimental`.

These tests are for 
* `scala.annotation.MacroAnnotation`
* `scala.annotation.MainAnnotation`
* `scala.annotation.newMain`
* `scala.util.TupledFunction`
* Expreminetal definitions in `scala.quoted.Quotes`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This PR cannot be merged until the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant