From 0699b7908e2f16a06e37158f3fc7fc0c58587bb1 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Mon, 5 Jan 2026 16:50:19 +0000 Subject: [PATCH] make unroll a preview feature --- .../reference/{experimental => preview}/unrolled-defs.md | 2 +- docs/sidebar.yml | 2 +- library/src/scala/annotation/unroll.scala | 3 ++- repl/test/dotty/tools/repl/ReplCompilerTests.scala | 2 +- sbt-test/tasty-compat/add-param-unroll/build.sbt | 2 +- tests/neg/unroll-abstractMethod.scala | 2 +- tests/neg/unroll-clash.scala | 2 +- tests/neg/unroll-clause-interleaving.scala | 2 +- tests/neg/unroll-duped.scala | 2 +- tests/neg/unroll-illegal.scala | 2 +- tests/neg/unroll-illegal2.scala | 2 +- tests/neg/unroll-illegal3.scala | 2 +- tests/neg/unroll-multipleParams.scala | 2 +- tests/neg/unroll-no-default.scala | 2 +- tests/neg/unroll-traitConstructor.scala | 2 +- tests/pos/i22833-unroll-final-class.scala | 7 ++++--- .../stdlibExperimentalDefinitions.scala | 3 --- tests/run/unroll-caseclass-integration/Unrolled_2.scala | 2 +- tests/run/unroll-caseclass-integration/Unrolled_3.scala | 2 +- tests/run/unroll-classMethod-integration/Unrolled_2.scala | 2 +- tests/run/unroll-classMethod-integration/Unrolled_3.scala | 2 +- tests/run/unroll-clause-interleaving/Unrolled_2.scala | 2 +- tests/run/unroll-clause-interleaving/Unrolled_3.scala | 2 +- .../run/unroll-curriedMethod-integration/Unrolled_2.scala | 2 +- .../run/unroll-curriedMethod-integration/Unrolled_3.scala | 2 +- .../run/unroll-genericMethod-integration/Unrolled_2.scala | 2 +- .../run/unroll-genericMethod-integration/Unrolled_3.scala | 2 +- tests/run/unroll-inferredFinal.scala | 2 +- .../unroll-methodWithImplicit-integration/Unrolled_2.scala | 2 +- .../unroll-methodWithImplicit-integration/Unrolled_3.scala | 2 +- tests/run/unroll-multiple.scala | 2 +- tests/run/unroll-objectMethod-integration/Unrolled_2.scala | 2 +- tests/run/unroll-objectMethod-integration/Unrolled_3.scala | 2 +- .../unroll-primaryConstructor-integration/Unrolled_2.scala | 2 +- .../unroll-primaryConstructor-integration/Unrolled_3.scala | 2 +- .../Unrolled_2.scala | 2 +- .../Unrolled_3.scala | 2 +- .../Unrolled_2.scala | 2 +- .../Unrolled_3.scala | 2 +- tests/run/unroll-traitMethod-integration/Unrolled_2.scala | 2 +- tests/run/unroll-traitMethod-integration/Unrolled_3.scala | 2 +- tests/run/unroll-value-class/Unrolled_2.scala | 2 +- tests/run/unroll-value-class/Unrolled_3.scala | 2 +- 43 files changed, 46 insertions(+), 47 deletions(-) rename docs/_docs/reference/{experimental => preview}/unrolled-defs.md (98%) diff --git a/docs/_docs/reference/experimental/unrolled-defs.md b/docs/_docs/reference/preview/unrolled-defs.md similarity index 98% rename from docs/_docs/reference/experimental/unrolled-defs.md rename to docs/_docs/reference/preview/unrolled-defs.md index f2e09e82bc18..7d36aeb39d54 100644 --- a/docs/_docs/reference/experimental/unrolled-defs.md +++ b/docs/_docs/reference/preview/unrolled-defs.md @@ -1,7 +1,7 @@ --- layout: doc-page title: "Automatic Parameter Unrolling" -nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/unrolled-defs.html +nightlyOf: https://docs.scala-lang.org/scala3/reference/preview/unrolled-defs.html --- Parameter unrolling enables new parameters to be added to methods and classes, diff --git a/docs/sidebar.yml b/docs/sidebar.yml index db10c2280a85..4b91e1cf5c84 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -143,6 +143,7 @@ subsection: index: reference/preview/overview.md subsection: - page: reference/preview/into.md + - page: reference/preview/unrolled-defs.md - title: Experimental Features directory: experimental index: reference/experimental/overview.md @@ -178,7 +179,6 @@ subsection: - page: reference/experimental/tupled-function.md - page: reference/experimental/modularity.md - page: reference/experimental/typeclasses.md - - page: reference/experimental/unrolled-defs.md - page: reference/experimental/package-object-values.md - page: reference/experimental/quoted-patterns-with-polymorphic-functions.md - page: reference/experimental/relaxed-lambdas.md diff --git a/library/src/scala/annotation/unroll.scala b/library/src/scala/annotation/unroll.scala index dcc279f93798..5cdcbc8dd9a2 100644 --- a/library/src/scala/annotation/unroll.scala +++ b/library/src/scala/annotation/unroll.scala @@ -1,8 +1,9 @@ package scala.annotation import language.experimental.captureChecking +import scala.annotation.internal.preview -@experimental("under review as part of SIP-61") +@preview /**The `@unroll` annotation is reserved for parameters of classes and methods. * * It enables to add new parameters while preserving backwards binary compatibility, diff --git a/repl/test/dotty/tools/repl/ReplCompilerTests.scala b/repl/test/dotty/tools/repl/ReplCompilerTests.scala index bf43d469111a..324f72e31ae9 100644 --- a/repl/test/dotty/tools/repl/ReplCompilerTests.scala +++ b/repl/test/dotty/tools/repl/ReplCompilerTests.scala @@ -582,7 +582,7 @@ class ReplHighlightTests extends ReplTest(ReplTest.defaultOptions.filterNot(_.st def deepTree(depth: Int): Tree deepTree(300)""") -class ReplUnrollTests extends ReplTest(ReplTest.defaultOptions ++ Seq("-experimental", "-Xprint:pickler")): +class ReplUnrollTests extends ReplTest(ReplTest.defaultOptions ++ Seq("-preview", "-Xprint:pickler")): override val redirectOutput = true @Test def i23408: Unit = initially: run(""" diff --git a/sbt-test/tasty-compat/add-param-unroll/build.sbt b/sbt-test/tasty-compat/add-param-unroll/build.sbt index e857fd5e1fac..f28aa34d142e 100644 --- a/sbt-test/tasty-compat/add-param-unroll/build.sbt +++ b/sbt-test/tasty-compat/add-param-unroll/build.sbt @@ -1,5 +1,5 @@ lazy val commonSettings = Seq( - scalacOptions += "-experimental", + scalacOptions += "-preview", ) lazy val printSettings = Seq( diff --git a/tests/neg/unroll-abstractMethod.scala b/tests/neg/unroll-abstractMethod.scala index 8f30fb63b20f..6ee0e00565b8 100644 --- a/tests/neg/unroll-abstractMethod.scala +++ b/tests/neg/unroll-abstractMethod.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-clash.scala b/tests/neg/unroll-clash.scala index 79a75c2ba785..a3a072c95157 100644 --- a/tests/neg/unroll-clash.scala +++ b/tests/neg/unroll-clash.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-clause-interleaving.scala b/tests/neg/unroll-clause-interleaving.scala index c40941320db1..eadbdd48abc8 100644 --- a/tests/neg/unroll-clause-interleaving.scala +++ b/tests/neg/unroll-clause-interleaving.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-duped.scala b/tests/neg/unroll-duped.scala index a578fc837628..cbb81b58bb3e 100644 --- a/tests/neg/unroll-duped.scala +++ b/tests/neg/unroll-duped.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-illegal.scala b/tests/neg/unroll-illegal.scala index 0b40a1c33c03..3f0c2b5642f5 100644 --- a/tests/neg/unroll-illegal.scala +++ b/tests/neg/unroll-illegal.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-illegal2.scala b/tests/neg/unroll-illegal2.scala index ad7284506bbf..60d8c3a058b5 100644 --- a/tests/neg/unroll-illegal2.scala +++ b/tests/neg/unroll-illegal2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-illegal3.scala b/tests/neg/unroll-illegal3.scala index 22a53bd04de6..15ecd2b9dd57 100644 --- a/tests/neg/unroll-illegal3.scala +++ b/tests/neg/unroll-illegal3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-multipleParams.scala b/tests/neg/unroll-multipleParams.scala index 80371fec74c4..a9ac6ccb3e70 100644 --- a/tests/neg/unroll-multipleParams.scala +++ b/tests/neg/unroll-multipleParams.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/neg/unroll-no-default.scala b/tests/neg/unroll-no-default.scala index 4529bc79f815..85b4ea3d1801 100644 --- a/tests/neg/unroll-no-default.scala +++ b/tests/neg/unroll-no-default.scala @@ -1,4 +1,4 @@ -//> using options -experimental -Vprint:unrollDefs +//> using options -preview -Vprint:unrollDefs import scala.annotation.unroll diff --git a/tests/neg/unroll-traitConstructor.scala b/tests/neg/unroll-traitConstructor.scala index 3c48852d8303..84e8b3766cc7 100644 --- a/tests/neg/unroll-traitConstructor.scala +++ b/tests/neg/unroll-traitConstructor.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/pos/i22833-unroll-final-class.scala b/tests/pos/i22833-unroll-final-class.scala index 1c5ef8cf0673..577e25dc8848 100644 --- a/tests/pos/i22833-unroll-final-class.scala +++ b/tests/pos/i22833-unroll-final-class.scala @@ -1,5 +1,6 @@ -import scala.annotation.{experimental,unroll} +//> using options -preview +import scala.annotation.unroll -@experimental final class Foo { +final class Foo { def bar(@unroll x: Int = 0) = x + 1 -} \ No newline at end of file +} diff --git a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala index 4cfb23e229ac..a0e52e53663a 100644 --- a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala +++ b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala @@ -93,9 +93,6 @@ val experimentalDefinitionInLibrary = Set( // Need quotedPatternsWithPolymorphicFunctions enabled. "scala.quoted.runtime.Patterns$.higherOrderHoleWithTypes", - // New feature: SIP 61 - @unroll annotation - "scala.annotation.unroll", - // New feature: Erased trait "scala.compiletime.Erased", ) diff --git a/tests/run/unroll-caseclass-integration/Unrolled_2.scala b/tests/run/unroll-caseclass-integration/Unrolled_2.scala index cb2232a57726..bb8f7c456213 100644 --- a/tests/run/unroll-caseclass-integration/Unrolled_2.scala +++ b/tests/run/unroll-caseclass-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-caseclass-integration/Unrolled_3.scala b/tests/run/unroll-caseclass-integration/Unrolled_3.scala index 66b4981660df..b13afde9c118 100644 --- a/tests/run/unroll-caseclass-integration/Unrolled_3.scala +++ b/tests/run/unroll-caseclass-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-classMethod-integration/Unrolled_2.scala b/tests/run/unroll-classMethod-integration/Unrolled_2.scala index 2091bb4c5a9e..a67535d9a22f 100644 --- a/tests/run/unroll-classMethod-integration/Unrolled_2.scala +++ b/tests/run/unroll-classMethod-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-classMethod-integration/Unrolled_3.scala b/tests/run/unroll-classMethod-integration/Unrolled_3.scala index 8991bda3aeb7..c2642545d486 100644 --- a/tests/run/unroll-classMethod-integration/Unrolled_3.scala +++ b/tests/run/unroll-classMethod-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-clause-interleaving/Unrolled_2.scala b/tests/run/unroll-clause-interleaving/Unrolled_2.scala index 5adc2bc924ec..4d4236d6aeb4 100644 --- a/tests/run/unroll-clause-interleaving/Unrolled_2.scala +++ b/tests/run/unroll-clause-interleaving/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/run/unroll-clause-interleaving/Unrolled_3.scala b/tests/run/unroll-clause-interleaving/Unrolled_3.scala index e23b9d12843a..8fd826cdb07c 100644 --- a/tests/run/unroll-clause-interleaving/Unrolled_3.scala +++ b/tests/run/unroll-clause-interleaving/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/run/unroll-curriedMethod-integration/Unrolled_2.scala b/tests/run/unroll-curriedMethod-integration/Unrolled_2.scala index 5a526bf6eeb2..6cc9624fb96e 100644 --- a/tests/run/unroll-curriedMethod-integration/Unrolled_2.scala +++ b/tests/run/unroll-curriedMethod-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-curriedMethod-integration/Unrolled_3.scala b/tests/run/unroll-curriedMethod-integration/Unrolled_3.scala index 008576a9a5c3..b49d66a9ff3a 100644 --- a/tests/run/unroll-curriedMethod-integration/Unrolled_3.scala +++ b/tests/run/unroll-curriedMethod-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-genericMethod-integration/Unrolled_2.scala b/tests/run/unroll-genericMethod-integration/Unrolled_2.scala index e5970388fff8..3c0f36097b8b 100644 --- a/tests/run/unroll-genericMethod-integration/Unrolled_2.scala +++ b/tests/run/unroll-genericMethod-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-genericMethod-integration/Unrolled_3.scala b/tests/run/unroll-genericMethod-integration/Unrolled_3.scala index 2ababa300ed1..af528e278ac6 100644 --- a/tests/run/unroll-genericMethod-integration/Unrolled_3.scala +++ b/tests/run/unroll-genericMethod-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-inferredFinal.scala b/tests/run/unroll-inferredFinal.scala index b4e1ccd9f011..e85362374ac6 100644 --- a/tests/run/unroll-inferredFinal.scala +++ b/tests/run/unroll-inferredFinal.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/run/unroll-methodWithImplicit-integration/Unrolled_2.scala b/tests/run/unroll-methodWithImplicit-integration/Unrolled_2.scala index 01a5d2fb037a..141daba42af5 100644 --- a/tests/run/unroll-methodWithImplicit-integration/Unrolled_2.scala +++ b/tests/run/unroll-methodWithImplicit-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-methodWithImplicit-integration/Unrolled_3.scala b/tests/run/unroll-methodWithImplicit-integration/Unrolled_3.scala index 07627f604d76..b00a8c6a09c7 100644 --- a/tests/run/unroll-methodWithImplicit-integration/Unrolled_3.scala +++ b/tests/run/unroll-methodWithImplicit-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-multiple.scala b/tests/run/unroll-multiple.scala index e1790be26395..eee06e37f9c6 100644 --- a/tests/run/unroll-multiple.scala +++ b/tests/run/unroll-multiple.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll import scala.deriving.Mirror diff --git a/tests/run/unroll-objectMethod-integration/Unrolled_2.scala b/tests/run/unroll-objectMethod-integration/Unrolled_2.scala index bfef86beb6b2..cc41553c0f49 100644 --- a/tests/run/unroll-objectMethod-integration/Unrolled_2.scala +++ b/tests/run/unroll-objectMethod-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-objectMethod-integration/Unrolled_3.scala b/tests/run/unroll-objectMethod-integration/Unrolled_3.scala index c76521e731d8..bb61878e8a05 100644 --- a/tests/run/unroll-objectMethod-integration/Unrolled_3.scala +++ b/tests/run/unroll-objectMethod-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-primaryConstructor-integration/Unrolled_2.scala b/tests/run/unroll-primaryConstructor-integration/Unrolled_2.scala index c8558df1af55..afb1ca847591 100644 --- a/tests/run/unroll-primaryConstructor-integration/Unrolled_2.scala +++ b/tests/run/unroll-primaryConstructor-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-primaryConstructor-integration/Unrolled_3.scala b/tests/run/unroll-primaryConstructor-integration/Unrolled_3.scala index c6be439e1dec..65a3fa7ac8ac 100644 --- a/tests/run/unroll-primaryConstructor-integration/Unrolled_3.scala +++ b/tests/run/unroll-primaryConstructor-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-secondParameterList-integration/Unrolled_2.scala b/tests/run/unroll-secondParameterList-integration/Unrolled_2.scala index 68c4170f6f6e..b3480251b58b 100644 --- a/tests/run/unroll-secondParameterList-integration/Unrolled_2.scala +++ b/tests/run/unroll-secondParameterList-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-secondParameterList-integration/Unrolled_3.scala b/tests/run/unroll-secondParameterList-integration/Unrolled_3.scala index ddbe8c4cfaf4..4e56b4ad16f6 100644 --- a/tests/run/unroll-secondParameterList-integration/Unrolled_3.scala +++ b/tests/run/unroll-secondParameterList-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-secondaryConstructor-integration/Unrolled_2.scala b/tests/run/unroll-secondaryConstructor-integration/Unrolled_2.scala index b8f1f4f28328..741950afb060 100644 --- a/tests/run/unroll-secondaryConstructor-integration/Unrolled_2.scala +++ b/tests/run/unroll-secondaryConstructor-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-secondaryConstructor-integration/Unrolled_3.scala b/tests/run/unroll-secondaryConstructor-integration/Unrolled_3.scala index 1da3e0d69ec6..38c18b6279c6 100644 --- a/tests/run/unroll-secondaryConstructor-integration/Unrolled_3.scala +++ b/tests/run/unroll-secondaryConstructor-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-traitMethod-integration/Unrolled_2.scala b/tests/run/unroll-traitMethod-integration/Unrolled_2.scala index 242054d41be4..4a1250ce62c0 100644 --- a/tests/run/unroll-traitMethod-integration/Unrolled_2.scala +++ b/tests/run/unroll-traitMethod-integration/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-traitMethod-integration/Unrolled_3.scala b/tests/run/unroll-traitMethod-integration/Unrolled_3.scala index 398ddbb4da22..26ab13a8fbec 100644 --- a/tests/run/unroll-traitMethod-integration/Unrolled_3.scala +++ b/tests/run/unroll-traitMethod-integration/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview package unroll import scala.annotation.unroll diff --git a/tests/run/unroll-value-class/Unrolled_2.scala b/tests/run/unroll-value-class/Unrolled_2.scala index 1be3f4ee38b6..06237865931e 100644 --- a/tests/run/unroll-value-class/Unrolled_2.scala +++ b/tests/run/unroll-value-class/Unrolled_2.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll diff --git a/tests/run/unroll-value-class/Unrolled_3.scala b/tests/run/unroll-value-class/Unrolled_3.scala index 05e5399bbe53..872504b998db 100644 --- a/tests/run/unroll-value-class/Unrolled_3.scala +++ b/tests/run/unroll-value-class/Unrolled_3.scala @@ -1,4 +1,4 @@ -//> using options -experimental +//> using options -preview import scala.annotation.unroll