Skip to content

Commit 9973893

Browse files
committed
Disable experimental by default in unstable builds
1 parent 7f14d85 commit 9973893

File tree

25 files changed

+34
-37
lines changed

25 files changed

+34
-37
lines changed

Diff for: compiler/src/dotty/tools/dotc/config/Feature.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,14 @@ object Feature:
163163
s"""Experimental $which may only be used under experimental mode:
164164
| 1. in a definition marked as @experimental, or
165165
| 2. an experimental feature is imported at the package level, or
166-
| 3. compiling with the -experimental compiler flag, or
167-
| 4. with a nightly or snapshot version of the compiler.
166+
| 3. compiling with the -experimental compiler flag.
168167
|""".stripMargin
169168

170169
def isExperimentalEnabled(using Context): Boolean =
171-
(Properties.unstableExperimentalEnabled && !ctx.settings.YnoExperimental.value) ||
172170
ctx.settings.experimental.value ||
173171
experimentalAutoEnableFeatures.exists(enabled)
174172

175173
def isExperimentalEnabledBySetting(using Context): Boolean =
176-
(Properties.unstableExperimentalEnabled && !ctx.settings.YnoExperimental.value) ||
177174
ctx.settings.experimental.value ||
178175
experimentalAutoEnableFeatures.exists(enabledBySetting)
179176

Diff for: compiler/src/dotty/tools/dotc/config/Properties.scala

-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ trait PropertiesTrait {
8484
*/
8585
val versionString: String = "version " + simpleVersionString
8686

87-
/** Whether the current version of compiler is experimental
88-
*
89-
* Snapshot, nightly releases and non-bootstrapped compiler are experimental.
90-
*/
91-
val unstableExperimentalEnabled: Boolean = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY") || versionString.contains("nonbootstrapped")
92-
9387
/** Whether the current version of compiler supports research plugins. */
9488
val researchPluginEnabled: Boolean = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY") || versionString.contains("nonbootstrapped")
9589

Diff for: compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ private sealed trait YSettings:
402402
val YretainTrees: Setting[Boolean] = BooleanSetting(ForkSetting, "Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
403403
val YshowTreeIds: Setting[Boolean] = BooleanSetting(ForkSetting, "Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
404404
val YfromTastyIgnoreList: 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.")
405-
val YnoExperimental: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-experimental", "Disable experimental language features by default in NIGHTLY/SNAPSHOT versions of the compiler.")
405+
val YnoExperimental: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-experimental", "Disable experimental language features by default in NIGHTLY/SNAPSHOT versions of the compiler (deprecated, no-op).")
406406
val YlegacyLazyVals: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylegacy-lazy-vals", "Use legacy (pre 3.3.0) implementation of lazy vals.")
407407
val YcompileScala2Library: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycompile-scala2-library", "Used when compiling the Scala 2 standard library.")
408408
val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Youtput-only-tasty", "Used to only generate the TASTy file without the classfiles")

Diff for: compiler/test/dotty/tools/backend/jvm/PublicInBinaryTests.scala

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class PublicInBinaryTests extends DottyBytecodeTest {
4242
override def initCtx =
4343
val ctx0 = super.initCtx
4444
ctx0.setSetting(ctx0.settings.experimental, true)
45-
ctx0.setSetting(ctx0.settings.YnoExperimental, true)
4645

4746
@Test
4847
def publicInBinaryDef(): Unit = {

Diff for: docs/_docs/reference/other-new-features/experimental-defs.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,7 @@ Experimental definitions can only be referenced in an experimental scope. Experi
265265

266266
</details>
267267

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.
270-
271-
7. An experimental language feature is imported in at the package level. All top-level definitions will be marked as `@experimental`.
268+
6. An experimental language feature is imported in at the package level. All top-level definitions will be marked as `@experimental`.
272269

273270
In any other situation, a reference to an experimental definition will cause a compilation error.
274271

Diff for: project/Build.scala

+3
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,9 @@ object Build {
17491749
SourceLinksIntegrationTest / scalaSource := baseDirectory.value / "test-source-links",
17501750
SourceLinksIntegrationTest / test:= ((SourceLinksIntegrationTest / test) dependsOn generateScalaDocumentation.toTask("")).value,
17511751
).
1752+
settings(
1753+
scalacOptions += "-experimental" // workaround use of experimental .info in Scaladoc2AnchorCreator
1754+
).
17521755
settings(
17531756
Compile / resourceGenerators ++= Seq(
17541757
generateStaticAssetsTask.taskValue,

Diff for: scaladoc-testcases/src/tests/hugetype.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait E:
3131
@deprecated
3232
protected implicit def same[A](a: A): A
3333

34-
trait XD extends E:
34+
@experimental trait XD extends E:
3535
/**
3636
* Some important information :o
3737
*

Diff for: scaladoc-testcases/src/tests/methodsAndConstructors.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package tests.methodsAndConstructors
22

3+
import scala.language.experimental.clauseInterleaving
4+
35
class A
46
class B extends A
57
class C
@@ -60,8 +62,6 @@ class Methods:
6062
def withImplicitParam2(v: String)(implicit ab: Double, a: Int, b: String): String
6163
= ???
6264

63-
import scala.language.experimental.clauseInterleaving
64-
6565
def clauseInterleaving[T](x: T)[U](y: U)(using (T, U)): (T, U)
6666
= ???
6767

Diff for: scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompiler.scala

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class SnippetCompiler(
2727
object SnippetDriver extends Driver:
2828
val currentCtx =
2929
val rootCtx = initCtx.fresh.addMode(Mode.ReadPositions).addMode(Mode.Interactive)
30-
rootCtx.setSetting(rootCtx.settings.YnoExperimental, true)
3130
rootCtx.setSetting(rootCtx.settings.experimental, true)
3231
rootCtx.setSetting(rootCtx.settings.YretainTrees, true)
3332
rootCtx.setSetting(rootCtx.settings.YcookComments, true)

Diff for: tests/neg/experimental-message-experimental-flag.check

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
| Experimental definition may only be used under experimental mode:
88
| 1. in a definition marked as @experimental, or
99
| 2. an experimental feature is imported at the package level, or
10-
| 3. compiling with the -experimental compiler flag, or
11-
| 4. with a nightly or snapshot version of the compiler.
10+
| 3. compiling with the -experimental compiler flag.

Diff for: tests/neg/experimental-message.check

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
| Experimental definition may only be used under experimental mode:
77
| 1. in a definition marked as @experimental, or
88
| 2. an experimental feature is imported at the package level, or
9-
| 3. compiling with the -experimental compiler flag, or
10-
| 4. with a nightly or snapshot version of the compiler.
9+
| 3. compiling with the -experimental compiler flag.
1110
-- Error: tests/neg/experimental-message.scala:16:2 --------------------------------------------------------------------
1211
16 | f2() // error
1312
| ^^
@@ -16,8 +15,7 @@
1615
| Experimental definition may only be used under experimental mode:
1716
| 1. in a definition marked as @experimental, or
1817
| 2. an experimental feature is imported at the package level, or
19-
| 3. compiling with the -experimental compiler flag, or
20-
| 4. with a nightly or snapshot version of the compiler.
18+
| 3. compiling with the -experimental compiler flag.
2119
-- Error: tests/neg/experimental-message.scala:17:2 --------------------------------------------------------------------
2220
17 | f3() // error
2321
| ^^
@@ -26,5 +24,4 @@
2624
| Experimental definition may only be used under experimental mode:
2725
| 1. in a definition marked as @experimental, or
2826
| 2. an experimental feature is imported at the package level, or
29-
| 3. compiling with the -experimental compiler flag, or
30-
| 4. with a nightly or snapshot version of the compiler.
27+
| 3. compiling with the -experimental compiler flag.

Diff for: tests/neg/i13091.check

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
| Experimental definition may only be used under experimental mode:
1313
| 1. in a definition marked as @experimental, or
1414
| 2. an experimental feature is imported at the package level, or
15-
| 3. compiling with the -experimental compiler flag, or
16-
| 4. with a nightly or snapshot version of the compiler.
15+
| 3. compiling with the -experimental compiler flag.

Diff for: tests/neg/overrides.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
class Foo {
24
type A = Int
35
type B >: Int <: Int

Diff for: tests/neg/use-experimental-def.check

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@
66
| Experimental definition may only be used under experimental mode:
77
| 1. in a definition marked as @experimental, or
88
| 2. an experimental feature is imported at the package level, or
9-
| 3. compiling with the -experimental compiler flag, or
10-
| 4. with a nightly or snapshot version of the compiler.
9+
| 3. compiling with the -experimental compiler flag.

Diff for: tests/pos-custom-args/captures/curried-closures.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
object Test:
24
def map2(xs: List[Int])(f: Int => Int): List[Int] = xs.map(f)
35
val f1 = map2

Diff for: tests/pos-macros/erasedArgs/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
//> using options -experimental
2+
13
def test: "1abc" = mcr

Diff for: tests/pos/TupleReverse.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import scala.Tuple.*
24
def test[T1, T2, T3, T4] =
35
summon[Reverse[EmptyTuple] =:= EmptyTuple]
File renamed without changes.

Diff for: tests/pos/i13091.scala

-3
This file was deleted.

Diff for: tests/pos/overrides.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
//> using options -experimental
2+
13
class A[T] {
24

35
def f(x: T)(y: T = x) = y
4-
6+
57
import scala.language.experimental.clauseInterleaving
68

79
def b[U <: T](x: Int)[V >: T](y: String) = false

Diff for: tests/pos/phantom-Eq2/Phantom-Eq_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//> using options -experimental
12

23
/* This is a version of ../pos/phantom.scala that tests phantom clases with separate compilation */
34
object PhantomEq {

Diff for: tests/run-macros/i17105/Test_3.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import reflect.Selectable.reflectiveSelectable
24

35
class Hoe { def f(x: Int): String = s"Hoe got ${x}" }

Diff for: tests/run-macros/macro-erased/Test_2.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
object Test {
24
def main(args: Array[String]): Unit = {
35
assert(Macro.foo1(1) == 0)

Diff for: tests/run/interleaving.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import scala.language.experimental.clauseInterleaving
2+
13
object Test extends App {
2-
import scala.language.experimental.clauseInterleaving
34
trait Key { type Value }
45
trait DB {
56
def getOrElse(k: Key)[V >: k.Value](default: V): V // dependent type parameter

Diff for: tests/run/publicInBinary/Test_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//> using options -experimental
12
import foo.*
23

34
@main def Test: Unit =

0 commit comments

Comments
 (0)