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
Enable experimental mode when experimental feature is imported (#19807)
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.
We also remove the special case that makes all code generated with a
nightly or snapshot compiler compile as if in experimental mode. This
implies that now the behavior of nightlies is identical to the behavior
of release versions. The `-Yno-experimental` becomes a no-op and will be
removed in a later PR.
[test_scala2_library_tasty]
valYretainTrees:Setting[Boolean] =BooleanSetting(ForkSetting, "Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
407
407
valYshowTreeIds:Setting[Boolean] =BooleanSetting(ForkSetting, "Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
408
408
valYfromTastyIgnoreList:Setting[List[String]] =MultiStringSetting(ForkSetting, "Yfrom-tasty-ignore-list", "file", "List of `tasty` files in jar files that will not be loaded when using -from-tasty.")
409
-
valYnoExperimental:Setting[Boolean] =BooleanSetting(ForkSetting, "Yno-experimental", "Disable experimental language features by default in NIGHTLY/SNAPSHOT versions of the compiler.")
Copy file name to clipboardExpand all lines: docs/_docs/reference/other-new-features/experimental-defs.md
+1-2
Original file line number
Diff line number
Diff line change
@@ -265,8 +265,7 @@ Experimental definitions can only be referenced in an experimental scope. Experi
265
265
266
266
</details>
267
267
268
-
6. Any code compiled using a [_Nightly_](https://search.maven.org/artifact/org.scala-lang/scala3-compiler_3) or _Snapshot_ version of the compiler is considered to be in an experimental scope.
269
-
Can use the `-Yno-experimental` compiler flag to disable it and run as a proper release.
268
+
6. An experimental language feature is imported in at the package level. All top-level definitions will be marked as `@experimental`.
270
269
271
270
In any other situation, a reference to an experimental definition will cause a compilation error.
0 commit comments