You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
+1-1
Original file line number
Diff line number
Diff line change
@@ -117,7 +117,7 @@ trait CommonScalaSettings:
117
117
vallanguage:Setting[List[ChoiceWithHelp[String]]] =MultiChoiceHelpSetting(RootSetting, "language", "feature", "Enable one or more language features.", choices =ScalaSettingsProperties.supportedLanguageFeatures, legacyChoices =ScalaSettingsProperties.legacyLanguageFeatures, default =Nil, aliases =List("--language"))
118
118
valexperimental:Setting[Boolean] =BooleanSetting(RootSetting, "experimental", "Annotate all top-level definitions with @experimental. This enables the use of experimental features anywhere in the project.")
119
119
valpreview:Setting[Boolean] =BooleanSetting(RootSetting, "preview", "Enable the use of preview features anywhere in the project.")
120
-
120
+
121
121
/* Coverage settings */
122
122
valcoverageOutputDir=PathSetting(RootSetting, "coverage-out", "Destination for coverage classfiles and instrumentation data.", "", aliases =List("--coverage-out"))
123
123
valcoverageExcludeClasslikes:Setting[List[String]] =MultiStringSetting(RootSetting, "coverage-exclude-classlikes", "packages, classes and modules", "List of regexes for packages, classes and modules to exclude from coverage.", aliases =List("--coverage-exclude-classlikes"))
The [`@preview`](https://scala-lang.org/api/3.x/scala/annotation/preview.html) annotation allows the definition of an API that is not guaranteed backward binary, but might become stable in next minor version of the compiler.
7
+
New Scala language features or standard library APIs are initially introduced as experimental, but once they become fully implemented and acceppted by the [SIP](https://docs.scala-lang.org/sips/) these can become a preview features.
8
+
Preview language features and APIs are guaranteed to be standarized in some next Scala minor release, but allow compiler team to introduce small, possibly binary incompatible, changes based on the community feedback.
9
+
These can be used by early adopters who can accept possibility of binary compatibility breakage. As an example these can be used for project internal tools and applications, but are discouraged to be used by libraries.
8
10
9
-
New Scala language features or standard library APIs initially introduced as experimental can become a preview features when they have become fully implemented and acceppted by the [SIP](https://docs.scala-lang.org/sips/) before they're accepted as standard features.
10
-
Such definitions can be used by early adopters that can accept possibility of binary compatibility breakage, for example these can be used for project internal tools and applications, but are discouraged to be used by libraries.
11
-
12
-
The [`@preview`](https://scala-lang.org/api/3.x/scala/annotation/preview.html) definitions follows similar rules as the [`@experimental`](https://scala-lang.org/api/3.x/scala/annotation/experimental.html) - to enable access to preview feature or API in given compilation unit Scala compiler requires either:
13
-
14
-
- explicit `-preview` flag passed to the compiler,
15
-
- top level import for explicit `scala.language.preview.<feature>`,
16
-
- annotating defintion that referes to preview feature with `@preview`
11
+
Users can enable access to preview features and definitions by compiling with `-preview` flag. The flag would enable all preview features and definitions. There is no way for enabling only a subset of preview features.
17
12
18
13
The biggest difference of preview features when compared with experimental features is their non-viral behaviour.
19
-
Any defintion that was compiles in the preview scope (using `-preview` flag or `scala.language.preview` top-level import) is not annotated as `@preview` defintion itself. It behaviour allows to use preview features transitively in other compilation units without enabled preview mode.
14
+
Any defintion compiled in the preview mode (using `-preview` flag) is not marked as preview defintion itself.
15
+
This behaviour allows to use preview features transitively in other compilation units without explicitlly enabled preview mode, as long as it does not directly reference APIs or features marked as preview.
16
+
17
+
The [`@preview`](https://scala-lang.org/api/3.x/scala/annotation/internal/preview.html) annotations are used to mark Scala 3 standard library APIs currently available under enabled preview mode.
18
+
The definitions follows similar rules as the [`@experimental`](https://scala-lang.org/api/3.x/scala/annotation/experimental.html) when it comes to accessing, subtyping, overriding or overloading definitions marked with this annotation - all of these can only be performed in compilation unit that enables preview mode.
0 commit comments