diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213 index c397bb4fc241..2361c1f0373f 160000 --- a/community-build/community-projects/stdLib213 +++ b/community-build/community-projects/stdLib213 @@ -1 +1 @@ -Subproject commit c397bb4fc24126822df8f1c73d621d450b4129b1 +Subproject commit 2361c1f0373f8af5418abe393bb85663f8f95259 diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index a44b44d6085f..673c21c3a42c 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -10,9 +10,6 @@ lazy val compilerVersion: String = val file = communitybuildDir.resolve("scala3-bootstrapped.version") new String(Files.readAllBytes(file), UTF_8) -lazy val compilerSupportExperimental: Boolean = - compilerVersion.contains("SNAPSHOT") || compilerVersion.contains("NIGHTLY") - lazy val sbtPluginFilePath: String = // Workaround for https://github.com/sbt/sbt/issues/4395 new File(sys.props("user.home") + "/.sbt/1.0/plugins").mkdirs() diff --git a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala index cbcd721fd64a..9c056bdb9ac4 100644 --- a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala +++ b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala @@ -116,7 +116,7 @@ class CommunityBuildTestB extends CommunityBuildTest: @Test def disciplineSpecs2 = projects.disciplineSpecs2.run() @Test def munit = projects.munit.run() @Test def perspective = projects.perspective.run() - @Test def scodec = if (compilerSupportExperimental) projects.scodec.run() + @Test def scodec = projects.scodec.run() @Test def scodecBits = projects.scodecBits.run() @Test def simulacrumScalafixAnnotations = projects.simulacrumScalafixAnnotations.run() end CommunityBuildTestB diff --git a/compiler/src/dotty/tools/dotc/Driver.scala b/compiler/src/dotty/tools/dotc/Driver.scala index 26f0faf433e7..03b946c74d9f 100644 --- a/compiler/src/dotty/tools/dotc/Driver.scala +++ b/compiler/src/dotty/tools/dotc/Driver.scala @@ -77,7 +77,6 @@ class Driver { val ictx = rootCtx.fresh val summary = command.distill(args, ictx.settings)(ictx.settingsState)(using ictx) ictx.setSettings(summary.sstate) - Feature.checkExperimentalFlags(using ictx) MacroClassLoader.init(ictx) Positioned.init(using ictx) diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index 64ab7bf079d0..950cf8be9b56 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -279,11 +279,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => def isLanguageImport(path: Tree): Boolean = languageImport(path).isDefined - def isExperimentalImport(path: Tree): Boolean = - languageImport(path) match - case Some(nme.experimental) => true - case _ => false - /** The underlying pattern ignoring any bindings */ def unbind(x: Tree): Tree = unsplice(x) match { case Bind(_, y) => unbind(y) diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index a0c53e0f58dd..182dd4aed248 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -28,19 +28,7 @@ object Feature: val symbolLiterals = deprecated("symbolLiterals") val fewerBraces = experimental("fewerBraces") - val experimentalWarningMessage = "Experimental features may only be used with nightly or snapshot version of compiler." - - /** Experimental features are only enabled for snapshot and nightly compiler versions - */ - def experimentalEnabled(using Context): Boolean = - Properties.experimental && !ctx.settings.YnoExperimental.value - - def isExperimental(feature: TermName): Boolean = - feature != scala2macros && feature.match - case QualifiedName(nme.experimental, _) => true - case _ => false - - /** Is `feature` enabled by by a command-line setting? The enabling setting is +/** Is `feature` enabled by by a command-line setting? The enabling setting is * * -language:feature * @@ -68,12 +56,9 @@ object Feature: * @param feature The name of the feature * @param owner The prefix symbol (nested in `scala.language`) where the * feature is defined. - * - * Note: Experimental features are only enabled for snapshot and nightly version of compiler. */ def enabled(feature: TermName)(using Context): Boolean = - (experimentalEnabled || !isExperimental(feature)) - && (enabledBySetting(feature) || enabledByImport(feature)) + enabledBySetting(feature) || enabledByImport(feature) /** Is auto-tupling enabled? */ def autoTuplingEnabled(using Context): Boolean = !enabled(nme.noAutoTupling) @@ -86,8 +71,6 @@ object Feature: def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals) - def erasedEnabled(using Context) = enabled(Feature.erasedDefinitions) - def scala2ExperimentalMacroEnabled(using Context) = enabled(scala2macros) def sourceVersionSetting(using Context): SourceVersion = @@ -114,16 +97,4 @@ object Feature: else false - /** Check that experimental compiler options are only set for snapshot or nightly compiler versions. */ - def checkExperimentalFlags(using Context): Unit = - if !experimentalEnabled then - val features = ctx.settings.language.value.filter { feature => - feature.contains(nme.experimental.toString) && !feature.contains("macros") - } - if features.nonEmpty then - report.error( - experimentalWarningMessage + - "\nThe experimental language features are enabled via -language:" + features.mkString(",") - ) - end Feature \ No newline at end of file diff --git a/compiler/src/dotty/tools/dotc/config/Properties.scala b/compiler/src/dotty/tools/dotc/config/Properties.scala index 3ec49d8eef68..4e084e050cf6 100644 --- a/compiler/src/dotty/tools/dotc/config/Properties.scala +++ b/compiler/src/dotty/tools/dotc/config/Properties.scala @@ -11,7 +11,7 @@ import java.nio.charset.StandardCharsets /** Loads `library.properties` from the jar. */ object Properties extends PropertiesTrait { protected def propCategory: String = "compiler" - protected def pickJarBasedOn: Class[PropertiesTrait] = classOf[PropertiesTrait] + protected def pickJarBasedOn: Class[Option[?]] = classOf[Option[?]] /** Scala manifest attributes. */ diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index ad1e0ad7151a..cf00cd131ef0 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -215,7 +215,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings { val YretainTrees: Setting[Boolean] = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree") val YshowTreeIds: Setting[Boolean] = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.") 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") - val YnoExperimental: Setting[Boolean] = BooleanSetting("-Yno-experimental", "Disable experimental language features") val YprofileEnabled: Setting[Boolean] = BooleanSetting("-Yprofile-enabled", "Enable profiling.") val YprofileDestination: Setting[String] = StringSetting("-Yprofile-destination", "file", "Where to send profiling output - specify a file, default is to the console.", "") diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index acb6a2ac39b5..076010399651 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -520,7 +520,6 @@ object StdNames { val longHash: N = "longHash" val macroThis : N = "_this" val macroContext : N = "c" - val macros: N = "macros" val main: N = "main" val manifest: N = "manifest" val ManifestFactory: N = "ManifestFactory" diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 048296b8ec83..66817e59da10 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -32,7 +32,6 @@ import config.Feature import config.Feature.{sourceVersion, migrateTo3} import config.SourceVersion._ import config.SourceVersion -import config.Properties object Parsers { @@ -3080,11 +3079,6 @@ object Parsers { val imp = Import(tree, selectors) if isLanguageImport(tree) then in.languageImportContext = in.languageImportContext.importContext(imp, NoSymbol) - if isExperimentalImport(tree) - && !Feature.experimentalEnabled - && selectors.exists(_.name != nme.macros) - then - report.error(Feature.experimentalWarningMessage, imp.srcPos) for case ImportSelector(id @ Ident(imported), EmptyTree, _) <- selectors if allSourceVersionNames.contains(imported) diff --git a/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala b/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala index f9b1d2e44df6..3af7d5e676b3 100644 --- a/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala @@ -118,6 +118,7 @@ class BootstrappedOnlyCompilationTests { aggregateTests( compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros")), compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees"), + compileFilesInDir("tests/run-custom-args/run-macros-erased", defaultOptions.and("-language:experimental.erasedDefinitions").and("-Xcheck-macros")), ) }.checkRuns() @@ -198,24 +199,6 @@ class BootstrappedOnlyCompilationTests { compileFilesInDir("tests/plugins/neg").checkExpectedErrors() compileDir("tests/plugins/custom/analyzer", withCompilerOptions.and("-Yretain-trees")).checkCompile() } - - // tests for experimental featuress ------------------------------------------ - - @Test def experimental: Unit = - implicit val testGroup: TestGroup = TestGroup("experimental") - val enableExperimental = defaultOptions.without("-Yno-experimental") - val enableErased = enableExperimental.and("-language:experimental.erasedDefinitions") - compileFilesInDir("tests/neg-custom-args/no-experimental", defaultOptions.and("-Yno-experimental")).checkExpectedErrors() - if config.Properties.experimental then - compileFilesInDir("tests/run-custom-args/experimental", enableExperimental).checkRuns() - compileFilesInDir("tests/neg-custom-args/experimental", enableExperimental).checkExpectedErrors() - compileFilesInDir("tests/pos-custom-args/experimental", enableExperimental).checkCompile() - compileFilesInDir("tests/run-staging-experimental", withStagingOptions.without("-Yno-experimental")).checkRuns() - compileFilesInDir("tests/neg-custom-args/erased", enableErased).checkExpectedErrors() - compileFilesInDir("tests/pos-custom-args/erased", enableErased).checkCompile() - compileFilesInDir("tests/run-custom-args/run-macros-erased", enableErased.and("-Xcheck-macros")).checkRuns() - compileFilesInDir("tests/run-custom-args/erased", enableErased) - } object BootstrappedOnlyCompilationTests extends ParallelTesting { diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index ff98ce498d35..4d040788f686 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -39,6 +39,7 @@ class CompilationTests { compileFilesInDir("tests/pos-special/isInstanceOf", allowDeepSubtypes.and("-Xfatal-warnings")), compileFilesInDir("tests/new", defaultOptions), compileFilesInDir("tests/pos-scala2", scala2CompatMode), + compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")), compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init")), compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes), compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")), @@ -125,6 +126,7 @@ class CompilationTests { compileFilesInDir("tests/neg-no-kind-polymorphism", defaultOptions and "-Yno-kind-polymorphism"), compileFilesInDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")), compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")), + compileFilesInDir("tests/neg-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")), compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings), compileFilesInDir("tests/neg-custom-args/allow-deep-subtypes", allowDeepSubtypes), compileFilesInDir("tests/neg-custom-args/explicit-nulls", defaultOptions.and("-Yexplicit-nulls")), @@ -163,7 +165,9 @@ class CompilationTests { compileDir("tests/neg-custom-args/adhoc-extension", defaultOptions.and("-source", "future", "-feature", "-Xfatal-warnings")), compileFile("tests/neg/i7575.scala", defaultOptions.withoutLanguageFeatures.and("-language:_")), compileFile("tests/neg-custom-args/kind-projector.scala", defaultOptions.and("-Ykind-projector")), + compileFile("tests/neg-custom-args/typeclass-derivation2.scala", defaultOptions.and("-language:experimental.erasedDefinitions")), compileFile("tests/neg-custom-args/i5498-postfixOps.scala", defaultOptions withoutLanguageFeature "postfixOps"), + compileFile("tests/neg-custom-args/deptypes.scala", defaultOptions.and("-language:experimental.dependent")), compileFile("tests/neg-custom-args/matchable.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")), compileFile("tests/neg-custom-args/i7314.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")), compileFile("tests/neg-custom-args/feature-shadowing.scala", defaultOptions.and("-Xfatal-warnings", "-feature")), @@ -185,6 +189,7 @@ class CompilationTests { compileFile("tests/run-custom-args/fors.scala", defaultOptions.and("-source", "future")), compileFile("tests/run-custom-args/no-useless-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"), compileFile("tests/run-custom-args/defaults-serizaliable-no-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"), + compileFilesInDir("tests/run-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")), compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes), compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init")) ).checkRuns() @@ -243,6 +248,7 @@ class CompilationTests { val lib = compileList("lib", librarySources, defaultOptions.and("-Ycheck-reentrant", + "-language:experimental.erasedDefinitions", // support declaration of scala.compiletime.erasedValue // "-source", "future", // TODO: re-enable once we allow : @unchecked in pattern definitions. Right now, lots of narrowing pattern definitions fail. ))(libGroup) diff --git a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala index 35c7e56060e5..8d1c9fa5cd86 100644 --- a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala +++ b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala @@ -9,7 +9,6 @@ object TestConfiguration { val noCheckOptions = Array( "-pagewidth", "120", "-color:never", - "-Yno-experimental", "-Xtarget", defaultTarget ) diff --git a/project/Build.scala b/project/Build.scala index 402bc133125f..9dc136eeb3cc 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -466,8 +466,6 @@ object Build { // Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)), - scalacOptions += "-Yno-experimental", - javaOptions ++= { val managedSrcDir = { // Populate the directory diff --git a/tests/neg-custom-args/experimental/deptypes.scala b/tests/neg-custom-args/deptypes.scala similarity index 90% rename from tests/neg-custom-args/experimental/deptypes.scala rename to tests/neg-custom-args/deptypes.scala index f656d54b8cfc..f01be10f2217 100644 --- a/tests/neg-custom-args/experimental/deptypes.scala +++ b/tests/neg-custom-args/deptypes.scala @@ -1,4 +1,3 @@ -import language.experimental.dependent type Vec[T] = (n: Int) =>> Array[T] // error: not yet implemented diff --git a/tests/neg-custom-args/no-experimental/experimental.scala b/tests/neg-custom-args/no-experimental/experimental.scala deleted file mode 100644 index 2d7aa39973bf..000000000000 --- a/tests/neg-custom-args/no-experimental/experimental.scala +++ /dev/null @@ -1,59 +0,0 @@ -class Test0 { - import language.experimental.namedTypeArguments // error - object Foo { - inline def f[S, T](x: S): T = ??? - def g(x: Int) = f[T = Any](x) // error - } -} - -class Test1 { - import language.experimental.erasedDefinitions // error - import scala.compiletime.erasedValue - type UnivEq[A] - object UnivEq: - erased def force[A]: UnivEq[A] = erasedValue // error // error // error - extension [A](erased proof: UnivEq[A]) // error - inline def univEq(a: A, b: A): Boolean = - a == b -} - -class Test2 { - import scala.language.experimental.genericNumberLiterals // error - val x: BigInt = 13232202002020202020202 // error - val y: BigInt = -0xaabb12345ACF12345AC // error -} - -class Test3 { - import scala.language.experimental.namedTypeArguments // error - object Foo { - inline def f[S, T](x: S): T = ??? - def g(x: Int) = f[T = Any](x) // error - } -} - -class Test4 { - import scala.language.experimental.erasedDefinitions // error - import scala.compiletime.erasedValue - type UnivEq[A] - object UnivEq: - erased def force[A]: UnivEq[A] = erasedValue // error // error // error - extension [A](erased proof: UnivEq[A]) // error - inline def univEq(a: A, b: A): Boolean = - a == b -} - -class Test5 { - import scala.language.experimental.genericNumberLiterals // error - val x: BigInt = 13232202002020202020202 // error - val y: BigInt = -0xaabb12345ACF12345AC // error -} - -class Test6 { - import scala.language.experimental -} - -class Test7 { - import scala.language.experimental - import experimental.genericNumberLiterals // error: no aliases can be used to refer to a language import - val x: BigInt = 13232202002020202020202 // error -} \ No newline at end of file diff --git a/tests/neg-custom-args/erased/typeclass-derivation2.scala b/tests/neg-custom-args/typeclass-derivation2.scala similarity index 99% rename from tests/neg-custom-args/erased/typeclass-derivation2.scala rename to tests/neg-custom-args/typeclass-derivation2.scala index 3ccd13a7ef0f..75e549413027 100644 --- a/tests/neg-custom-args/erased/typeclass-derivation2.scala +++ b/tests/neg-custom-args/typeclass-derivation2.scala @@ -1,5 +1,3 @@ -import language.experimental.erasedDefinitions - import scala.collection.mutable import scala.annotation.tailrec diff --git a/tests/neg-custom-args/experimental/BigFloat/BigFloatFromDigitsImpl_1.scala b/tests/neg-macros/BigFloat/BigFloatFromDigitsImpl_1.scala similarity index 100% rename from tests/neg-custom-args/experimental/BigFloat/BigFloatFromDigitsImpl_1.scala rename to tests/neg-macros/BigFloat/BigFloatFromDigitsImpl_1.scala diff --git a/tests/neg-custom-args/experimental/BigFloat/BigFloat_1.scala b/tests/neg-macros/BigFloat/BigFloat_1.scala similarity index 99% rename from tests/neg-custom-args/experimental/BigFloat/BigFloat_1.scala rename to tests/neg-macros/BigFloat/BigFloat_1.scala index 47f036bbd362..5bb5b49587bd 100644 --- a/tests/neg-custom-args/experimental/BigFloat/BigFloat_1.scala +++ b/tests/neg-macros/BigFloat/BigFloat_1.scala @@ -48,3 +48,4 @@ object BigFloat extends App { '{BigInt(${Expr(x.toString)})} } } + diff --git a/tests/neg-custom-args/experimental/BigFloat/Test_2.scala b/tests/neg-macros/BigFloat/Test_2.scala similarity index 100% rename from tests/neg-custom-args/experimental/BigFloat/Test_2.scala rename to tests/neg-macros/BigFloat/Test_2.scala diff --git a/tests/neg-custom-args/experimental/GenericNumLits/EvenFromDigitsImpl_1.scala b/tests/neg-macros/GenericNumLits/EvenFromDigitsImpl_1.scala similarity index 100% rename from tests/neg-custom-args/experimental/GenericNumLits/EvenFromDigitsImpl_1.scala rename to tests/neg-macros/GenericNumLits/EvenFromDigitsImpl_1.scala diff --git a/tests/neg-custom-args/experimental/GenericNumLits/Even_1.scala b/tests/neg-macros/GenericNumLits/Even_1.scala similarity index 100% rename from tests/neg-custom-args/experimental/GenericNumLits/Even_1.scala rename to tests/neg-macros/GenericNumLits/Even_1.scala diff --git a/tests/neg-custom-args/experimental/GenericNumLits/Test_2.scala b/tests/neg-macros/GenericNumLits/Test_2.scala similarity index 100% rename from tests/neg-custom-args/experimental/GenericNumLits/Test_2.scala rename to tests/neg-macros/GenericNumLits/Test_2.scala diff --git a/tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala b/tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala new file mode 100644 index 000000000000..2c8e0d088ea8 --- /dev/null +++ b/tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala @@ -0,0 +1,19 @@ +import language.experimental.genericNumberLiterals +import scala.util.FromDigits +import scala.quoted.* +import Even.* + +object EvenFromDigitsImpl: + def apply(digits: Expr[String])(using Quotes): Expr[Even] = digits.value match { + case Some(ds) => + val ev = + try evenFromDigits(ds) + catch { + case ex: FromDigits.FromDigitsException => + quotes.reflect.report.error(ex.getMessage) + Even(0) + } + '{Even(${Expr(ev.n)})} + case _ => + '{evenFromDigits($digits)} + } diff --git a/tests/neg-with-compiler/GenericNumLits/Even_1.scala b/tests/neg-with-compiler/GenericNumLits/Even_1.scala new file mode 100644 index 000000000000..0867150dd944 --- /dev/null +++ b/tests/neg-with-compiler/GenericNumLits/Even_1.scala @@ -0,0 +1,24 @@ +import language.experimental.genericNumberLiterals +import scala.util.FromDigits +import scala.quoted.* + + +case class Even(n: Int) +object Even { + + def evenFromDigits(digits: String): Even = { + val intValue = FromDigits.intFromDigits(digits) + if (intValue % 2 == 0) Even(intValue) + else throw FromDigits.MalformedNumber(s"$digits is odd") + } + + class EvenFromDigits extends FromDigits[Even] { + def fromDigits(digits: String) = evenFromDigits(digits) + } + + given EvenFromDigits with { + override inline def fromDigits(digits: String) = ${ + EvenFromDigitsImpl('digits) + } + } +} diff --git a/tests/neg-with-compiler/GenericNumLits/Test_2.scala b/tests/neg-with-compiler/GenericNumLits/Test_2.scala new file mode 100644 index 000000000000..579fca249337 --- /dev/null +++ b/tests/neg-with-compiler/GenericNumLits/Test_2.scala @@ -0,0 +1,6 @@ +import language.experimental.genericNumberLiterals +object Test extends App { + + val e1: Even = 1234 + val e2: Even = 123 // error: 123 is odd +} \ No newline at end of file diff --git a/tests/neg-custom-args/experimental/closure-args.scala b/tests/neg/closure-args.scala similarity index 100% rename from tests/neg-custom-args/experimental/closure-args.scala rename to tests/neg/closure-args.scala diff --git a/tests/neg-custom-args/experimental/erased-class.scala b/tests/neg/erased-class.scala similarity index 100% rename from tests/neg-custom-args/experimental/erased-class.scala rename to tests/neg/erased-class.scala diff --git a/tests/neg-custom-args/experimental/erased-inheritance.scala b/tests/neg/erased-inheritance.scala similarity index 99% rename from tests/neg-custom-args/experimental/erased-inheritance.scala rename to tests/neg/erased-inheritance.scala index ac61160b3901..7be71e1632a5 100644 --- a/tests/neg-custom-args/experimental/erased-inheritance.scala +++ b/tests/neg/erased-inheritance.scala @@ -8,3 +8,5 @@ erased trait D val x = new A{} // ok, x is erased val y = new C with D{} // error + + diff --git a/tests/neg-custom-args/experimental/i2771.scala b/tests/neg/i2771.scala similarity index 100% rename from tests/neg-custom-args/experimental/i2771.scala rename to tests/neg/i2771.scala diff --git a/tests/neg-custom-args/experimental/i5328.scala b/tests/neg/i5328.scala similarity index 100% rename from tests/neg-custom-args/experimental/i5328.scala rename to tests/neg/i5328.scala diff --git a/tests/neg-custom-args/experimental/i7751.scala b/tests/neg/i7751.scala similarity index 100% rename from tests/neg-custom-args/experimental/i7751.scala rename to tests/neg/i7751.scala diff --git a/tests/neg-custom-args/experimental/indent-experimental.scala b/tests/neg/indent-experimental.scala similarity index 100% rename from tests/neg-custom-args/experimental/indent-experimental.scala rename to tests/neg/indent-experimental.scala diff --git a/tests/neg-custom-args/experimental/language-import.scala b/tests/neg/language-import.scala similarity index 99% rename from tests/neg-custom-args/experimental/language-import.scala rename to tests/neg/language-import.scala index b3226de5eeb2..8f498f091f75 100644 --- a/tests/neg-custom-args/experimental/language-import.scala +++ b/tests/neg/language-import.scala @@ -20,3 +20,4 @@ object d: import language.experimental.genericNumberLiterals // ok import scala.language.noAutoTupling // ok import _root_.scala.language.strictEquality // ok + diff --git a/tests/neg-custom-args/experimental/namedTypeParams.scala b/tests/neg/namedTypeParams.scala similarity index 100% rename from tests/neg-custom-args/experimental/namedTypeParams.scala rename to tests/neg/namedTypeParams.scala diff --git a/tests/neg-custom-args/experimental/safeThrowsStrawman.scala b/tests/neg/safeThrowsStrawman.scala similarity index 100% rename from tests/neg-custom-args/experimental/safeThrowsStrawman.scala rename to tests/neg/safeThrowsStrawman.scala diff --git a/tests/neg-custom-args/experimental/safeThrowsStrawman2.scala b/tests/neg/safeThrowsStrawman2.scala similarity index 100% rename from tests/neg-custom-args/experimental/safeThrowsStrawman2.scala rename to tests/neg/safeThrowsStrawman2.scala diff --git a/tests/neg-custom-args/experimental/scala2-macro-compat-no-scala3-implementation.scala b/tests/neg/scala2-macro-compat-no-scala3-implementation.scala similarity index 100% rename from tests/neg-custom-args/experimental/scala2-macro-compat-no-scala3-implementation.scala rename to tests/neg/scala2-macro-compat-no-scala3-implementation.scala diff --git a/tests/pos-custom-args/experimental/CanThrow.scala b/tests/pos/CanThrow.scala similarity index 100% rename from tests/pos-custom-args/experimental/CanThrow.scala rename to tests/pos/CanThrow.scala diff --git a/tests/pos-custom-args/experimental/closure-args.scala b/tests/pos/closure-args.scala similarity index 100% rename from tests/pos-custom-args/experimental/closure-args.scala rename to tests/pos/closure-args.scala diff --git a/tests/pos-custom-args/experimental/erased-class-separate/A_1.scala b/tests/pos/erased-class-separate/A_1.scala similarity index 98% rename from tests/pos-custom-args/experimental/erased-class-separate/A_1.scala rename to tests/pos/erased-class-separate/A_1.scala index 9d159374f9c8..5c874ce6d89b 100644 --- a/tests/pos-custom-args/experimental/erased-class-separate/A_1.scala +++ b/tests/pos/erased-class-separate/A_1.scala @@ -1,2 +1,3 @@ import language.experimental.erasedDefinitions erased class A + diff --git a/tests/pos-custom-args/experimental/erased-class-separate/Test_2.scala b/tests/pos/erased-class-separate/Test_2.scala similarity index 100% rename from tests/pos-custom-args/experimental/erased-class-separate/Test_2.scala rename to tests/pos/erased-class-separate/Test_2.scala diff --git a/tests/pos-custom-args/experimental/erased-conforms.scala b/tests/pos/erased-conforms.scala similarity index 100% rename from tests/pos-custom-args/experimental/erased-conforms.scala rename to tests/pos/erased-conforms.scala diff --git a/tests/pos-custom-args/experimental/gadt-GadtStlc.scala b/tests/pos/gadt-GadtStlc.scala similarity index 100% rename from tests/pos-custom-args/experimental/gadt-GadtStlc.scala rename to tests/pos/gadt-GadtStlc.scala diff --git a/tests/pos-custom-args/experimental/gadt-TypeSafeLambda.scala b/tests/pos/gadt-TypeSafeLambda.scala similarity index 100% rename from tests/pos-custom-args/experimental/gadt-TypeSafeLambda.scala rename to tests/pos/gadt-TypeSafeLambda.scala diff --git a/tests/pos-custom-args/experimental/i11743.scala b/tests/pos/i11743.scala similarity index 100% rename from tests/pos-custom-args/experimental/i11743.scala rename to tests/pos/i11743.scala diff --git a/tests/pos-custom-args/experimental/i3666-gadt.scala b/tests/pos/i3666-gadt.scala similarity index 100% rename from tests/pos-custom-args/experimental/i3666-gadt.scala rename to tests/pos/i3666-gadt.scala diff --git a/tests/pos-custom-args/experimental/i3955.scala b/tests/pos/i3955.scala similarity index 100% rename from tests/pos-custom-args/experimental/i3955.scala rename to tests/pos/i3955.scala diff --git a/tests/pos-custom-args/experimental/i5328.scala b/tests/pos/i5328.scala similarity index 100% rename from tests/pos-custom-args/experimental/i5328.scala rename to tests/pos/i5328.scala diff --git a/tests/pos-custom-args/experimental/indent-colons.scala b/tests/pos/indent-colons.scala similarity index 100% rename from tests/pos-custom-args/experimental/indent-colons.scala rename to tests/pos/indent-colons.scala diff --git a/tests/pos-custom-args/experimental/kindPolySemiGroup.scala b/tests/pos/kindPolySemiGroup.scala similarity index 100% rename from tests/pos-custom-args/experimental/kindPolySemiGroup.scala rename to tests/pos/kindPolySemiGroup.scala diff --git a/tests/pos-custom-args/experimental/named-typeargs.scala b/tests/pos/named-typeargs.scala similarity index 100% rename from tests/pos-custom-args/experimental/named-typeargs.scala rename to tests/pos/named-typeargs.scala diff --git a/tests/pos-custom-args/experimental/namedTypeParams.scala b/tests/pos/namedTypeParams.scala similarity index 100% rename from tests/pos-custom-args/experimental/namedTypeParams.scala rename to tests/pos/namedTypeParams.scala diff --git a/tests/pos-custom-args/experimental/t1513a.scala b/tests/pos/t1513a.scala similarity index 100% rename from tests/pos-custom-args/experimental/t1513a.scala rename to tests/pos/t1513a.scala diff --git a/tests/pos-custom-args/experimental/t1513b.scala b/tests/pos/t1513b.scala similarity index 100% rename from tests/pos-custom-args/experimental/t1513b.scala rename to tests/pos/t1513b.scala diff --git a/tests/pos-custom-args/experimental/typeclass-encoding3.scala b/tests/pos/typeclass-encoding3.scala similarity index 100% rename from tests/pos-custom-args/experimental/typeclass-encoding3.scala rename to tests/pos/typeclass-encoding3.scala diff --git a/tests/run-custom-args/experimental/BigFloat/BigFloatFromDigitsImpl_1.scala b/tests/run-macros/BigFloat/BigFloatFromDigitsImpl_1.scala similarity index 100% rename from tests/run-custom-args/experimental/BigFloat/BigFloatFromDigitsImpl_1.scala rename to tests/run-macros/BigFloat/BigFloatFromDigitsImpl_1.scala diff --git a/tests/run-custom-args/experimental/BigFloat/BigFloat_1.scala b/tests/run-macros/BigFloat/BigFloat_1.scala similarity index 99% rename from tests/run-custom-args/experimental/BigFloat/BigFloat_1.scala rename to tests/run-macros/BigFloat/BigFloat_1.scala index 47f036bbd362..5bb5b49587bd 100644 --- a/tests/run-custom-args/experimental/BigFloat/BigFloat_1.scala +++ b/tests/run-macros/BigFloat/BigFloat_1.scala @@ -48,3 +48,4 @@ object BigFloat extends App { '{BigInt(${Expr(x.toString)})} } } + diff --git a/tests/run-custom-args/experimental/BigFloat/Test_2.scala b/tests/run-macros/BigFloat/Test_2.scala similarity index 100% rename from tests/run-custom-args/experimental/BigFloat/Test_2.scala rename to tests/run-macros/BigFloat/Test_2.scala diff --git a/tests/run-staging-experimental/staged-streams_1.scala b/tests/run-staging/staged-streams_1.scala similarity index 100% rename from tests/run-staging-experimental/staged-streams_1.scala rename to tests/run-staging/staged-streams_1.scala diff --git a/tests/run-custom-args/experimental/genericNumLits.scala b/tests/run/genericNumLits.scala similarity index 100% rename from tests/run-custom-args/experimental/genericNumLits.scala rename to tests/run/genericNumLits.scala diff --git a/tests/run-custom-args/experimental/hmap-covariant.scala b/tests/run/hmap-covariant.scala similarity index 100% rename from tests/run-custom-args/experimental/hmap-covariant.scala rename to tests/run/hmap-covariant.scala diff --git a/tests/run-custom-args/experimental/hmap.scala b/tests/run/hmap.scala similarity index 100% rename from tests/run-custom-args/experimental/hmap.scala rename to tests/run/hmap.scala diff --git a/tests/run-custom-args/experimental/polymorphic-functions.scala b/tests/run/polymorphic-functions.scala similarity index 100% rename from tests/run-custom-args/experimental/polymorphic-functions.scala rename to tests/run/polymorphic-functions.scala diff --git a/tests/run-custom-args/experimental/safeThrowsStrawman.scala b/tests/run/safeThrowsStrawman.scala similarity index 100% rename from tests/run-custom-args/experimental/safeThrowsStrawman.scala rename to tests/run/safeThrowsStrawman.scala diff --git a/tests/run-custom-args/experimental/safeThrowsStrawman2.scala b/tests/run/safeThrowsStrawman2.scala similarity index 100% rename from tests/run-custom-args/experimental/safeThrowsStrawman2.scala rename to tests/run/safeThrowsStrawman2.scala