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

Add @scala.annotation.internal.preview annotation and -preview flag. #22317

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

WojciechMazur
Copy link
Contributor

@WojciechMazur WojciechMazur commented Jan 7, 2025

This adds @scala.annotation.internal.preview to mark Scala 3 stdlib API as preview-only and accessors for easy marking Scala features in the compiler as preview (similarly to experimental features)

Access to preview features/API is granted to user using the -preview compiler flag - it enables all access to preview features/API without possibility to enable only their subset.

@preview annotated definitions follows the same rules as @experimental with exception of being non viral - we're not automatically adding @preview annotation to when refering to preview definitions, but still require preview scope (by -preview flag), we still check if class overloads, overrides or externs a definition marked as @preview.

Other difference is that @preview is private[scala] to prevent users from defining their own preview definitions as it was happening with @experimental

@soronpo
Copy link
Contributor

soronpo commented Jan 7, 2025

So what happens when a library uses a preview feature and publishes? A user can depend on it without turning on preview?

@WojciechMazur
Copy link
Contributor Author

So what happens when a library uses a preview feature and publishes? A user can depend on it without turning on preview?

Yes, user can depend on it without turning on preview as long as the exposed API does not use any preview features. Preview features can become an implementation detail that is not exposed to referrer of definition.

@Gedochao Gedochao added the release-notes Should be mentioned in the release notes label Jan 13, 2025
@WojciechMazur WojciechMazur changed the title Add @scala.annotation.preview annotation and -preview flag. Add @scala.annotation.internal.preview annotation and -preview flag. Jan 23, 2025
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes Should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce concept of Preview Features as a feature stabilization period
4 participants