diff --git a/community-build/community-projects/scala-parallel-collections b/community-build/community-projects/scala-parallel-collections index a6bd648bb188..7d0e41ae4d09 160000 --- a/community-build/community-projects/scala-parallel-collections +++ b/community-build/community-projects/scala-parallel-collections @@ -1 +1 @@ -Subproject commit a6bd648bb188a65ab36be07e956e52fe25f64d67 +Subproject commit 7d0e41ae4d09e1ddf063651e377921ec493fc5bf diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 64b8a91e9096..00bd0d168158 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -314,6 +314,7 @@ private sealed trait YSettings: 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 YlegacyLazyVals: Setting[Boolean] = BooleanSetting("-Ylegacy-lazy-vals", "Use legacy (pre 3.3.0) implementation of lazy vals") 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.", "") @@ -331,7 +332,6 @@ private sealed trait YSettings: val YrecheckTest: Setting[Boolean] = BooleanSetting("-Yrecheck-test", "Run basic rechecking (internal test only)") val YccDebug: Setting[Boolean] = BooleanSetting("-Ycc-debug", "Used in conjunction with captureChecking language import, debug info for captured references") val YccNoAbbrev: Setting[Boolean] = BooleanSetting("-Ycc-no-abbrev", "Used in conjunction with captureChecking language import, suppress type abbreviations") - val YlightweightLazyVals: Setting[Boolean] = BooleanSetting("-Ylightweight-lazy-vals", "Use experimental lightweight implementation of lazy vals") /** Area-specific debug output */ val YexplainLowlevel: Setting[Boolean] = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.") diff --git a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala index c428adbaebda..0a9a2b1214b2 100644 --- a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala +++ b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala @@ -448,10 +448,10 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer { def transformMemberDefThreadSafe(x: ValOrDefDef)(using Context): Thicket = { assert(!(x.symbol is Mutable)) - if ctx.settings.YlightweightLazyVals.value then - transformMemberDefThreadSafeNew(x) - else + if ctx.settings.YlegacyLazyVals.value then transformMemberDefThreadSafeLegacy(x) + else + transformMemberDefThreadSafeNew(x) } def transformMemberDefThreadSafeNew(x: ValOrDefDef)(using Context): Thicket = { diff --git a/compiler/test/dotc/run-lazy-vals-tests.allowlist b/compiler/test/dotc/run-lazy-vals-tests.allowlist index 98973dc2893d..361795bcc5fd 100644 --- a/compiler/test/dotc/run-lazy-vals-tests.allowlist +++ b/compiler/test/dotc/run-lazy-vals-tests.allowlist @@ -38,7 +38,6 @@ null-lazy-val.scala patmatch-classtag.scala priorityQueue.scala serialization-new-legacy.scala -serialization-new.scala singletons.scala statics.scala stream_flatmap_odds.scala diff --git a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala index 2c618ea91e96..71bf530fcda5 100644 --- a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala +++ b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala @@ -597,7 +597,7 @@ class DottyBytecodeTests extends DottyBytecodeTest { val clsIn = dir.lookupName("Test.class", directory = false).input val clsNode = loadClassNode(clsIn) val method = getMethod(clsNode, "test") - assertEquals(88, instructionsFromMethod(method).size) + assertEquals(23, instructionsFromMethod(method).size) } } diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 20daa2d24406..f1042be4839d 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -44,8 +44,8 @@ class CompilationTests { compileFilesInDir("tests/pos-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")), compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-language:experimental.erasedDefinitions")), compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init")), - // Run tests for experimental lightweight lazy vals - compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylightweight-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)), + // Run tests for legacy lazy vals + compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)), compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes), compileFilesInDir("tests/pos-custom-args/no-experimental", defaultOptions.and("-Yno-experimental")), compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")), @@ -211,9 +211,9 @@ class CompilationTests { compileDir("tests/run-custom-args/Xmacro-settings/compileTimeEnv", defaultOptions.and("-Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO")), compileFilesInDir("tests/run-custom-args/captures", allowDeepSubtypes.and("-language:experimental.captureChecking")), compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes), - compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init"), FileFilter.exclude("serialization-new.scala")), - // Run tests for experimental lightweight lazy vals and stable lazy vals. - compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init", "-Ylightweight-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.runLazyValsAllowlist)), + compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init")), + // Run tests for legacy lazy vals. + compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.runLazyValsAllowlist)), ).checkRuns() } diff --git a/library/src/scala/runtime/LazyVals.scala b/library/src/scala/runtime/LazyVals.scala index 98f67e804e3c..5d1e8e74b89d 100644 --- a/library/src/scala/runtime/LazyVals.scala +++ b/library/src/scala/runtime/LazyVals.scala @@ -45,28 +45,24 @@ object LazyVals { /* ------------- Start of public API ------------- */ - @experimental sealed trait LazyValControlState /** * Used to indicate the state of a lazy val that is being * evaluated and of which other threads await the result. */ - @experimental final class Waiting extends CountDownLatch(1) with LazyValControlState /** * Used to indicate the state of a lazy val that is currently being * evaluated with no other thread awaiting its result. */ - @experimental object Evaluating extends LazyValControlState /** * Used to indicate the state of a lazy val that has been evaluated to * `null`. */ - @experimental object NullValue extends LazyValControlState final val BITS_PER_LAZY_VAL = 2L @@ -86,7 +82,6 @@ object LazyVals { unsafe.compareAndSwapLong(t, offset, e, n) } - @experimental def objCAS(t: Object, offset: Long, exp: Object, n: Object): Boolean = { if (debug) println(s"objCAS($t, $exp, $n)") @@ -147,7 +142,6 @@ object LazyVals { r } - @experimental def getStaticFieldOffset(field: java.lang.reflect.Field): Long = { @nowarn val r = unsafe.staticFieldOffset(field) diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index cceffaf53279..ed1d11c66fd8 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -5,15 +5,6 @@ object MiMaFilters { val Library: Seq[ProblemFilter] = Seq( ProblemFilters.exclude[MissingClassProblem]("scala.annotation.internal.MappedAlternative"), - ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.LazyVals.getStaticFieldOffset"), - ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.LazyVals.objCAS"), - ProblemFilters.exclude[MissingClassProblem]("scala.runtime.LazyVals$LazyValControlState"), - ProblemFilters.exclude[MissingClassProblem]("scala.runtime.LazyVals$Evaluating$"), - ProblemFilters.exclude[MissingClassProblem]("scala.runtime.LazyVals$NullValue$"), - ProblemFilters.exclude[MissingClassProblem]("scala.runtime.LazyVals$Waiting"), - ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.LazyVals.Evaluating"), - ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.LazyVals.NullValue"), - ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language#experimental.into"), ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$experimental$into$"), ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language#experimental.pureFunctions"), diff --git a/tests/printing/transformed/lazy-vals-legacy.flags b/tests/printing/transformed/lazy-vals-legacy.flags new file mode 100644 index 000000000000..e785b42309f3 --- /dev/null +++ b/tests/printing/transformed/lazy-vals-legacy.flags @@ -0,0 +1 @@ +-Ylegacy-lazy-vals \ No newline at end of file diff --git a/tests/printing/transformed/lazy-vals-new.flags b/tests/printing/transformed/lazy-vals-new.flags deleted file mode 100644 index 51b77a4da919..000000000000 --- a/tests/printing/transformed/lazy-vals-new.flags +++ /dev/null @@ -1 +0,0 @@ --Ylightweight-lazy-vals diff --git a/tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala b/tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala index 422d88efc095..ca379c97141b 100644 --- a/tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala +++ b/tests/run-custom-args/tasty-inspector/stdlibExperimentalDefinitions.scala @@ -76,16 +76,6 @@ val experimentalDefinitionInLibrary = Set( "scala.quoted.Quotes.reflectModule.SymbolModule.newClass", "scala.quoted.Quotes.reflectModule.SymbolModule.freshName", "scala.quoted.Quotes.reflectModule.SymbolMethods.info", - - // New APIs: Lightweight lazy vals. Can be stabilized in 3.3.0 - "scala.runtime.LazyVals$.Evaluating", - "scala.runtime.LazyVals$.Evaluating$", - "scala.runtime.LazyVals$.LazyValControlState", - "scala.runtime.LazyVals$.NullValue", - "scala.runtime.LazyVals$.NullValue$", - "scala.runtime.LazyVals$.Waiting", - "scala.runtime.LazyVals$.getStaticFieldOffset", - "scala.runtime.LazyVals$.objCAS" )