Skip to content

Commit 8c353b1

Browse files
committed
Test with -Yno-experimental
1 parent b438c16 commit 8c353b1

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ object Feature:
9898
false
9999

100100
def allowExperimentalFeatures(using Context) =
101-
Config.allowExperimentalFeatures
101+
Config.allowExperimentalFeatures && !ctx.settings.YnoExperimental.value
102102

103103
def checkExperimentalFeature(which: String, srcPos: SrcPos = NoSourcePosition)(using Context) =
104104
if !allowExperimentalFeatures then

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
215215
val YretainTrees: Setting[Boolean] = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
216216
val YshowTreeIds: Setting[Boolean] = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
217217
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")
218+
val YnoExperimental: Setting[Boolean] = BooleanSetting("-Yno-experimental", "Disable experimental language features")
218219

219220
val YprofileEnabled: Setting[Boolean] = BooleanSetting("-Yprofile-enabled", "Enable profiling.")
220221
val YprofileDestination: Setting[String] = StringSetting("-Yprofile-destination", "file", "Where to send profiling output - specify a file, default is to the console.", "")

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class CompilationTests {
130130
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings),
131131
compileFilesInDir("tests/neg-custom-args/allow-deep-subtypes", allowDeepSubtypes),
132132
compileFilesInDir("tests/neg-custom-args/explicit-nulls", defaultOptions.and("-Yexplicit-nulls")),
133+
compileFilesInDir("tests/neg-custom-args/no-experimental", defaultOptions.and("-Yno-experimental")),
133134
compileDir("tests/neg-custom-args/impl-conv", defaultOptions.and("-Xfatal-warnings", "-feature")),
134135
compileFile("tests/neg-custom-args/implicit-conversions.scala", defaultOptions.and("-Xfatal-warnings", "-feature")),
135136
compileFile("tests/neg-custom-args/implicit-conversions-old.scala", defaultOptions.and("-Xfatal-warnings", "-feature")),
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Test0 {
2+
import language.experimental.namedTypeArguments // error
3+
object Foo {
4+
inline def f[S, T](x: S): T = ???
5+
def g(x: Int) = f[T = Any](x) // error
6+
}
7+
}
8+
9+
class Test1 {
10+
import language.experimental.erasedDefinitions // error
11+
import scala.compiletime.erasedValue
12+
type UnivEq[A]
13+
object UnivEq:
14+
erased def force[A]: UnivEq[A] = erasedValue // error // error // error
15+
extension [A](erased proof: UnivEq[A]) // error
16+
inline def univEq(a: A, b: A): Boolean =
17+
a == b
18+
}
19+
20+
class Test1 {
21+
import language.experimental.genericNumberLiterals // error
22+
val x: BigInt = 13232202002020202020202
23+
val y: BigInt = -0xaabb12345ACF12345AC
24+
}
25+

0 commit comments

Comments
 (0)