Skip to content

Commit eb477fd

Browse files
committed
Disable experimental by default in unstable builds
1 parent 64f92c5 commit eb477fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+82
-48
lines changed

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ object Feature:
142142
em"""Experimental $which may only be used under experimental mode:
143143
| 1. in a definition marked as @experimental, or
144144
| 2. an experimental feature is imported in at the package level, or
145-
| 3. compiling with the -experimental compiler flag, or
146-
| 4. with a nightly or snapshot version of the compiler.$note
145+
| 3. compiling with the -experimental compiler flag.$note
147146
|""", srcPos)
148147

149148
private def ccException(sym: Symbol)(using Context): Boolean =
@@ -162,7 +161,6 @@ object Feature:
162161
checkExperimentalFeature("definition", srcPos, s"\n\n$note")
163162

164163
def isExperimentalEnabledBySetting(using Context): Boolean =
165-
(Properties.unstableExperimentalEnabled && !ctx.settings.YnoExperimental.value) ||
166164
ctx.settings.experimental.value ||
167165
experimentalAutoEnableFeatures.exists(enabledBySetting)
168166

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
@@ -399,7 +399,7 @@ private sealed trait YSettings:
399399
val YretainTrees: Setting[Boolean] = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
400400
val YshowTreeIds: Setting[Boolean] = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
401401
val YfromTastyIgnoreList: Setting[List[String]] = MultiStringSetting("-Yfrom-tasty-ignore-list", "file", "List of `tasty` files in jar files that will not be loaded when using -from-tasty.")
402-
val YnoExperimental: Setting[Boolean] = BooleanSetting("-Yno-experimental", "Disable experimental language features by default in NIGHTLY/SNAPSHOT versions of the compiler.")
402+
val YnoExperimental: Setting[Boolean] = BooleanSetting("-Yno-experimental", "Disable experimental language features by default in NIGHTLY/SNAPSHOT versions of the compiler (deprecated, no-op).")
403403
val YlegacyLazyVals: Setting[Boolean] = BooleanSetting("-Ylegacy-lazy-vals", "Use legacy (pre 3.3.0) implementation of lazy vals.")
404404
val YcompileScala2Library: Setting[Boolean] = BooleanSetting("-Ycompile-scala2-library", "Used when compiling the Scala 2 standard library.")
405405
val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting("-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

Diff for: docs/_spec/TODOreference/other-new-features/experimental-defs.md

+1-4

Diff for: project/Build.scala

+3
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,9 @@ object Build {
17591759
SourceLinksIntegrationTest / scalaSource := baseDirectory.value / "test-source-links",
17601760
SourceLinksIntegrationTest / test:= ((SourceLinksIntegrationTest / test) dependsOn generateScalaDocumentation.toTask("")).value,
17611761
).
1762+
settings(
1763+
scalacOptions += "-experimental" // workaround use of experimental .info in Scaladoc2AnchorCreator
1764+
).
17621765
settings(
17631766
Compile / resourceGenerators ++= Seq(
17641767
generateStaticAssetsTask.taskValue,

Diff for: scala2-library-cc/src/scala/collection/generic/IsSeq.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ object IsSeq {
5858
* The helper method [[seqViewIsSeq_]] is added to make the binary compatible.
5959
*/
6060
@annotation.targetName("seqViewIsSeq")
61-
@annotation.publicInBinary
62-
private[IsSeq] def seqViewIsSeq_[CC0[X] <: SeqView[X], A0]: IsSeq[CC0[A0]] { type A = A0; type C = View[A0] } = ???
61+
// @annotation.publicInBinary private[IsSeq] // FIXME: enable when publicInBinary becomes stable
62+
def seqViewIsSeq_[CC0[X] <: SeqView[X], A0]: IsSeq[CC0[A0]] { type A = A0; type C = View[A0] } = ???
6363
implicit inline def seqViewIsSeq[CC0[X] <: SeqView[X], A0]: IsIterable[CC0[A0]] { type A = A0; type C = View[A0] } = seqViewIsSeq_[CC0, A0].asInstanceOf
6464

6565
/** !!! Under cc, views are not Seqs and can't use SeqOps.
6666
* Therefore, [[stringViewIsSeq]] now returns an [[IsIterable]].
6767
* The helper method [[stringViewIsSeq__]] is added to make the binary compatible.
6868
*/
6969
@annotation.targetName("stringViewIsSeq")
70-
@annotation.publicInBinary
71-
private[IsSeq] val stringViewIsSeq_ : IsSeq[StringView] { type A = Char; type C = View[Char] } = ???
70+
// @annotation.publicInBinary private[IsSeq] // FIXME: enable when publicInBinary becomes stable
71+
val stringViewIsSeq_ : IsSeq[StringView] { type A = Char; type C = View[Char] } = ???
7272
inline implicit def stringViewIsSeq: IsIterable[StringView] { type A = Char; type C = View[Char] } = stringViewIsSeq_.asInstanceOf
7373

7474
implicit val stringIsSeq: IsSeq[String] { type A = Char; type C = String } =

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

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

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

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,6 +27,7 @@ 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.experimental, true)
3031
rootCtx.setSetting(rootCtx.settings.YretainTrees, true)
3132
rootCtx.setSetting(rootCtx.settings.YcookComments, true)
3233
rootCtx.setSetting(rootCtx.settings.YreadComments, true)

Diff for: tests/init-global/pos/global-region1.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import scala.annotation.init.region
24

35
trait B { def foo(): Int }

Diff for: tests/init-global/warn/i18628_3.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import scala.annotation.init.widen
24

35
object Test:

Diff for: tests/neg-macros/i19842/Macro.scala

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

23
import scala.annotation.{experimental, targetName}
34
import scala.quoted.*

Diff for: tests/neg/experimental-nested-imports-2.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -Yno-experimental
2-
31
import annotation.experimental
42

53
class Class1:

Diff for: tests/neg/experimental-nested-imports-3.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -Yno-experimental
2-
31
import annotation.experimental
42

53
class Class1:

Diff for: tests/neg/experimental-nested-imports.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -Yno-experimental
2-
31
import annotation.experimental
42

53
class Class1:

Diff for: tests/neg/i13091.check

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- [E190] Potential Issue Warning: tests/neg/i13091.scala:7:17 ---------------------------------------------------------
2+
7 |def test: Unit = new Foo // error: class Foo is marked @experimental ...
3+
| ^^^^^^^
4+
| Discarded non-Unit value of type Foo. You may want to use `()`.
5+
|
6+
| longer explanation available when compiling with `-explain`
7+
-- Error: tests/neg/i13091.scala:7:21 ----------------------------------------------------------------------------------
8+
7 |def test: Unit = new Foo // error: class Foo is marked @experimental ...
9+
| ^^^
10+
| Experimental definition may only be used under experimental mode:
11+
| 1. in a definition marked as @experimental, or
12+
| 2. an experimental feature is imported in at the package level, or
13+
| 3. compiling with the -experimental compiler flag.
14+
|
15+
| class Foo is marked @experimental

Diff for: tests/neg/inline-unstable-accessors.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Werror -WunstableInlineAccessors -explain
1+
//> using options -experimental -Werror -WunstableInlineAccessors -explain
22

33
package foo
44
import scala.annotation.publicInBinary

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/publicInBinaryOverride.check

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- [E164] Declaration Error: tests/neg/publicInBinaryOverride.scala:8:15 -----------------------------------------------
2-
8 | override def f(): Unit = () // error
3-
| ^
4-
| error overriding method f in class A of type (): Unit;
5-
| method f of type (): Unit also needs to be declared with @publicInBinary
1+
-- [E164] Declaration Error: tests/neg/publicInBinaryOverride.scala:10:15 ----------------------------------------------
2+
10 | override def f(): Unit = () // error
3+
| ^
4+
| error overriding method f in class A of type (): Unit;
5+
| method f of type (): Unit also needs to be declared with @publicInBinary

Diff for: tests/neg/publicInBinaryOverride.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import scala.annotation.publicInBinary
24

35
class A:

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
| Experimental definition may only be used under experimental mode:
55
| 1. in a definition marked as @experimental, or
66
| 2. an experimental feature is imported in at the package level, or
7-
| 3. compiling with the -experimental compiler flag, or
8-
| 4. with a nightly or snapshot version of the compiler.
7+
| 3. compiling with the -experimental compiler flag.
98
|
109
| method foo is marked @experimental

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]

Diff for: tests/pos/TupleReverseOnto.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[ReverseOnto[(T1, T2), (T3, T4)] =:= ReverseOnto[(T1, T2), (T3, T4)]]

Diff for: tests/pos/expeimental-flag.scala renamed to tests/pos/experimental-flag.scala

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

33
import scala.annotation.experimental
44

Diff for: tests/pos/i13091.scala

-3
This file was deleted.

Diff for: tests/pos/i7851.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
trait Wrappable[T] { }
24
given Wrappable[Float] with { }
35

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/tupled-function-instances.scala

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

Diff for: tests/run-deep-subtype/Tuple-reverse.scala

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

35
object Test {

Diff for: tests/run-macros/i12021/Macro_1.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import scala.quoted.*
24

35
inline def inspect[A]: String =

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/i13215.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Werror -WunstableInlineAccessors
1+
//> using options -experimental -Werror -WunstableInlineAccessors
22

33
import scala.annotation.publicInBinary
44

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/noProtectedSuper.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import scala.annotation.publicInBinary
24

35
package p {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Werror -WunstableInlineAccessors
1+
//> using options -experimental -Werror -WunstableInlineAccessors
22

33
package foo
44

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 =

Diff for: tests/run/quotes-add-erased/Macro_1.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
import scala.annotation.MacroAnnotation
24
import scala.annotation.internal.ErasedParam
35
import scala.quoted._

Diff for: tests/run/quotes-reflection/Macros_1.scala

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
//> using options -experimental
3+
14
import scala.quoted.*
25

36
inline def inspect[A]: String =

0 commit comments

Comments
 (0)