Skip to content

Commit 3175ae1

Browse files
committed
Revert #11852: only enable experimental features for snapshot and nightly
This reverts PR #11852. See #11915.
1 parent 43a73a3 commit 3175ae1

File tree

64 files changed

+73
-108
lines changed

Some content is hidden

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

64 files changed

+73
-108
lines changed

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ lazy val compilerVersion: String =
1010
val file = communitybuildDir.resolve("scala3-bootstrapped.version")
1111
new String(Files.readAllBytes(file), UTF_8)
1212

13-
lazy val compilerSupportExperimental: Boolean =
14-
compilerVersion.contains("SNAPSHOT") || compilerVersion.contains("NIGHTLY")
15-
1613
lazy val sbtPluginFilePath: String =
1714
// Workaround for https://github.com/sbt/sbt/issues/4395
1815
new File(sys.props("user.home") + "/.sbt/1.0/plugins").mkdirs()

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class CommunityBuildTestB extends CommunityBuildTest:
116116
@Test def disciplineSpecs2 = projects.disciplineSpecs2.run()
117117
@Test def munit = projects.munit.run()
118118
@Test def perspective = projects.perspective.run()
119-
@Test def scodec = if (compilerSupportExperimental) projects.scodec.run()
119+
@Test def scodec = projects.scodec.run()
120120
@Test def scodecBits = projects.scodecBits.run()
121121
@Test def simulacrumScalafixAnnotations = projects.simulacrumScalafixAnnotations.run()
122122
end CommunityBuildTestB

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ object Feature:
3232

3333
/** Experimental features are only enabled for snapshot and nightly compiler versions
3434
*/
35-
def experimentalEnabled(using Context): Boolean =
36-
Properties.experimental && !ctx.settings.YnoExperimental.value
37-
38-
def isExperimental(feature: TermName): Boolean =
39-
feature != scala2macros && feature.match
40-
case QualifiedName(nme.experimental, _) => true
41-
case _ => false
35+
def checkExperimentalFeature(feature: TermName): Boolean =
36+
feature match
37+
case QualifiedName(nme.experimental, _) => Properties.experimental
38+
case _ => true
4239

4340
/** Is `feature` enabled by by a command-line setting? The enabling setting is
4441
*
@@ -72,8 +69,7 @@ object Feature:
7269
* Note: Experimental features are only enabled for snapshot and nightly version of compiler.
7370
*/
7471
def enabled(feature: TermName)(using Context): Boolean =
75-
(experimentalEnabled || !isExperimental(feature))
76-
&& (enabledBySetting(feature) || enabledByImport(feature))
72+
checkExperimentalFeature(feature) && (enabledBySetting(feature) || enabledByImport(feature))
7773

7874
/** Is auto-tupling enabled? */
7975
def autoTuplingEnabled(using Context): Boolean = !enabled(nme.noAutoTupling)
@@ -116,10 +112,8 @@ object Feature:
116112

117113
/** Check that experimental compiler options are only set for snapshot or nightly compiler versions. */
118114
def checkExperimentalFlags(using Context): Unit =
119-
if !experimentalEnabled then
120-
val features = ctx.settings.language.value.filter { feature =>
121-
feature.contains(nme.experimental.toString) && !feature.contains("macros")
122-
}
115+
if !Properties.experimental then
116+
val features = ctx.settings.language.value.filter(_.contains(nme.experimental.toString))
123117
if features.nonEmpty then
124118
report.error(
125119
experimentalWarningMessage +

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.nio.charset.StandardCharsets
1111
/** Loads `library.properties` from the jar. */
1212
object Properties extends PropertiesTrait {
1313
protected def propCategory: String = "compiler"
14-
protected def pickJarBasedOn: Class[PropertiesTrait] = classOf[PropertiesTrait]
14+
protected def pickJarBasedOn: Class[Option[?]] = classOf[Option[?]]
1515

1616
/** Scala manifest attributes.
1717
*/

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ 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")
219218

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

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ object StdNames {
520520
val longHash: N = "longHash"
521521
val macroThis : N = "_this"
522522
val macroContext : N = "c"
523-
val macros: N = "macros"
524523
val main: N = "main"
525524
val manifest: N = "manifest"
526525
val ManifestFactory: N = "ManifestFactory"

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,10 +3080,7 @@ object Parsers {
30803080
val imp = Import(tree, selectors)
30813081
if isLanguageImport(tree) then
30823082
in.languageImportContext = in.languageImportContext.importContext(imp, NoSymbol)
3083-
if isExperimentalImport(tree)
3084-
&& !Feature.experimentalEnabled
3085-
&& selectors.exists(_.name != nme.macros)
3086-
then
3083+
if isExperimentalImport(tree) && !Properties.experimental then
30873084
report.error(Feature.experimentalWarningMessage, imp.srcPos)
30883085
for
30893086
case ImportSelector(id @ Ident(imported), EmptyTree, _) <- selectors

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

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class BootstrappedOnlyCompilationTests {
118118
aggregateTests(
119119
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros")),
120120
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees"),
121+
compileFilesInDir("tests/run-custom-args/run-macros-erased", defaultOptions.and("-language:experimental.erasedDefinitions").and("-Xcheck-macros")),
121122
)
122123
}.checkRuns()
123124

@@ -198,24 +199,6 @@ class BootstrappedOnlyCompilationTests {
198199
compileFilesInDir("tests/plugins/neg").checkExpectedErrors()
199200
compileDir("tests/plugins/custom/analyzer", withCompilerOptions.and("-Yretain-trees")).checkCompile()
200201
}
201-
202-
// tests for experimental featuress ------------------------------------------
203-
204-
@Test def experimental: Unit =
205-
implicit val testGroup: TestGroup = TestGroup("experimental")
206-
val enableExperimental = defaultOptions.without("-Yno-experimental")
207-
val enableErased = enableExperimental.and("-language:experimental.erasedDefinitions")
208-
compileFilesInDir("tests/neg-custom-args/no-experimental", defaultOptions.and("-Yno-experimental")).checkExpectedErrors()
209-
if config.Properties.experimental then
210-
compileFilesInDir("tests/run-custom-args/experimental", enableExperimental).checkRuns()
211-
compileFilesInDir("tests/neg-custom-args/experimental", enableExperimental).checkExpectedErrors()
212-
compileFilesInDir("tests/pos-custom-args/experimental", enableExperimental).checkCompile()
213-
compileFilesInDir("tests/run-staging-experimental", withStagingOptions.without("-Yno-experimental")).checkRuns()
214-
compileFilesInDir("tests/neg-custom-args/erased", enableErased).checkExpectedErrors()
215-
compileFilesInDir("tests/pos-custom-args/erased", enableErased).checkCompile()
216-
compileFilesInDir("tests/run-custom-args/run-macros-erased", enableErased.and("-Xcheck-macros")).checkRuns()
217-
compileFilesInDir("tests/run-custom-args/erased", enableErased)
218-
219202
}
220203

221204
object BootstrappedOnlyCompilationTests extends ParallelTesting {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CompilationTests {
3939
compileFilesInDir("tests/pos-special/isInstanceOf", allowDeepSubtypes.and("-Xfatal-warnings")),
4040
compileFilesInDir("tests/new", defaultOptions),
4141
compileFilesInDir("tests/pos-scala2", scala2CompatMode),
42+
compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")),
4243
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init")),
4344
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes),
4445
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
@@ -125,6 +126,7 @@ class CompilationTests {
125126
compileFilesInDir("tests/neg-no-kind-polymorphism", defaultOptions and "-Yno-kind-polymorphism"),
126127
compileFilesInDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")),
127128
compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")),
129+
compileFilesInDir("tests/neg-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")),
128130
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings),
129131
compileFilesInDir("tests/neg-custom-args/allow-deep-subtypes", allowDeepSubtypes),
130132
compileFilesInDir("tests/neg-custom-args/explicit-nulls", defaultOptions.and("-Yexplicit-nulls")),
@@ -163,7 +165,9 @@ class CompilationTests {
163165
compileDir("tests/neg-custom-args/adhoc-extension", defaultOptions.and("-source", "future", "-feature", "-Xfatal-warnings")),
164166
compileFile("tests/neg/i7575.scala", defaultOptions.withoutLanguageFeatures.and("-language:_")),
165167
compileFile("tests/neg-custom-args/kind-projector.scala", defaultOptions.and("-Ykind-projector")),
168+
compileFile("tests/neg-custom-args/typeclass-derivation2.scala", defaultOptions.and("-language:experimental.erasedDefinitions")),
166169
compileFile("tests/neg-custom-args/i5498-postfixOps.scala", defaultOptions withoutLanguageFeature "postfixOps"),
170+
compileFile("tests/neg-custom-args/deptypes.scala", defaultOptions.and("-language:experimental.dependent")),
167171
compileFile("tests/neg-custom-args/matchable.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")),
168172
compileFile("tests/neg-custom-args/i7314.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")),
169173
compileFile("tests/neg-custom-args/feature-shadowing.scala", defaultOptions.and("-Xfatal-warnings", "-feature")),
@@ -185,6 +189,7 @@ class CompilationTests {
185189
compileFile("tests/run-custom-args/fors.scala", defaultOptions.and("-source", "future")),
186190
compileFile("tests/run-custom-args/no-useless-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
187191
compileFile("tests/run-custom-args/defaults-serizaliable-no-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
192+
compileFilesInDir("tests/run-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")),
188193
compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes),
189194
compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init"))
190195
).checkRuns()
@@ -243,6 +248,7 @@ class CompilationTests {
243248
val lib =
244249
compileList("lib", librarySources,
245250
defaultOptions.and("-Ycheck-reentrant",
251+
"-language:experimental.erasedDefinitions", // support declaration of scala.compiletime.erasedValue
246252
// "-source", "future", // TODO: re-enable once we allow : @unchecked in pattern definitions. Right now, lots of narrowing pattern definitions fail.
247253
))(libGroup)
248254

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ object TestConfiguration {
99
val noCheckOptions = Array(
1010
"-pagewidth", "120",
1111
"-color:never",
12-
"-Yno-experimental",
1312
"-Xtarget", defaultTarget
1413
)
1514

project/Build.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,6 @@ object Build {
466466
// Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL
467467
packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)),
468468

469-
scalacOptions += "-Yno-experimental",
470-
471469
javaOptions ++= {
472470
val managedSrcDir = {
473471
// Populate the directory

tests/neg-custom-args/experimental/deptypes.scala renamed to tests/neg-custom-args/deptypes.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import language.experimental.dependent
21

32
type Vec[T] = (n: Int) =>> Array[T] // error: not yet implemented
43

tests/neg-custom-args/no-experimental/experimental.scala

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/neg-custom-args/erased/typeclass-derivation2.scala renamed to tests/neg-custom-args/typeclass-derivation2.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import language.experimental.erasedDefinitions
2-
31
import scala.collection.mutable
42
import scala.annotation.tailrec
53

tests/neg-custom-args/experimental/BigFloat/BigFloat_1.scala renamed to tests/neg-macros/BigFloat/BigFloat_1.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ object BigFloat extends App {
4848
'{BigInt(${Expr(x.toString)})}
4949
}
5050
}
51+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import language.experimental.genericNumberLiterals
2+
import scala.util.FromDigits
3+
import scala.quoted.*
4+
import Even.*
5+
6+
object EvenFromDigitsImpl:
7+
def apply(digits: Expr[String])(using Quotes): Expr[Even] = digits.value match {
8+
case Some(ds) =>
9+
val ev =
10+
try evenFromDigits(ds)
11+
catch {
12+
case ex: FromDigits.FromDigitsException =>
13+
quotes.reflect.report.error(ex.getMessage)
14+
Even(0)
15+
}
16+
'{Even(${Expr(ev.n)})}
17+
case _ =>
18+
'{evenFromDigits($digits)}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import language.experimental.genericNumberLiterals
2+
import scala.util.FromDigits
3+
import scala.quoted.*
4+
5+
6+
case class Even(n: Int)
7+
object Even {
8+
9+
def evenFromDigits(digits: String): Even = {
10+
val intValue = FromDigits.intFromDigits(digits)
11+
if (intValue % 2 == 0) Even(intValue)
12+
else throw FromDigits.MalformedNumber(s"$digits is odd")
13+
}
14+
15+
class EvenFromDigits extends FromDigits[Even] {
16+
def fromDigits(digits: String) = evenFromDigits(digits)
17+
}
18+
19+
given EvenFromDigits with {
20+
override inline def fromDigits(digits: String) = ${
21+
EvenFromDigitsImpl('digits)
22+
}
23+
}
24+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import language.experimental.genericNumberLiterals
2+
object Test extends App {
3+
4+
val e1: Even = 1234
5+
val e2: Even = 123 // error: 123 is odd
6+
}

tests/neg-custom-args/experimental/erased-inheritance.scala renamed to tests/neg/erased-inheritance.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ erased trait D
88

99
val x = new A{} // ok, x is erased
1010
val y = new C with D{} // error
11+
12+

tests/neg-custom-args/experimental/language-import.scala renamed to tests/neg/language-import.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ object d:
2020
import language.experimental.genericNumberLiterals // ok
2121
import scala.language.noAutoTupling // ok
2222
import _root_.scala.language.strictEquality // ok
23+
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import language.experimental.erasedDefinitions
22
erased class A
3+

tests/run-custom-args/experimental/BigFloat/BigFloat_1.scala renamed to tests/run-macros/BigFloat/BigFloat_1.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ object BigFloat extends App {
4848
'{BigInt(${Expr(x.toString)})}
4949
}
5050
}
51+
File renamed without changes.

0 commit comments

Comments
 (0)