Skip to content

Commit 5854959

Browse files
authored
Lift Scala Settings from experimental to stabilized (#20199)
Fixes: #19693 This is the tracking list from the issue and the status of migraton. - [x] lift to `-X` - [x] `-Yresolve-term-conflict` - [x] `-YnoGenericSig` - [x] `-Ydumpclasses` - [x] `-YjarCompressionLevel` - [x] `-YkindProjector` - [x] `-YdropComments` - [x] `-YcookComments` - [x] `-YreadComments` - [x] `-YnoDecodeStacktraces` - [x] `-YnoEnrichErrorMessages` - [x] `-YdebugMacros` - [ ] `-YjavaTasty`- deprecate in 3.7.0 - [ ] `-YjavaTastyOutput`- deprecate in 3.7.0 - [ ] `-YallowOutlineFromTasty`- deprecate in 3.7.0 - [x] lift to `-W` - [x] `-Wsafe-init` - [x] to be removed - [x] `--Yforce-inline-while-typing` // Note: this was already removed by 05eb7f7 - [ ] TBD - [ ] `-YfromTastyIgnoreList` // this flag was not decided - [x] `-YoutputOnlyTasty` I suppose 2 last flags that have to be decided are maintained by @bishabosha Do you know their status ? Other than that, this PR implemented a deprecation mechanism for the future e.g. ```scala Deprecation( msg = "message", replacedBy = Some("newMessage"), ) ``` EDIT: As it was decided, options responsible for pipelining will be retained until 3.7.0. The code is commented and following PR which will deprecate them will be created after merging this one. EDIT2: `-Xlint` is a very problematic flag. It was added into the compiler in 3.4 bypassing argument verification. Then in the future, when it was deprecated in favour of `-Wshadow` we couldn't exactly map them 1-1, and it was deprecated in following way: - Scala 2: `-Xlint` is valid flag, - Scala pre 3.4: `-Xlint` was skipped as it was not implemented, - Scala post 3.4 pre flag refactor: `-Xlint` was implemented allowing for `all`, `private-shadow` and `type-parameter-shadow` options. It also bypassed argument verification allowing standalone `-Xlint` to be ignored, not reported as error, - Scala post 3.4 post flag refactor: This flag was then deprecated in favour of `-Wshadow`. We didn't want to commit this mistake again and allow standalone `-Wshadow` thus when it was deprecated, we didn't handle it as we should (deprecated option should trigger replacement when possible). That's why I'm retaining the previous behaviour of `-Xlint`. It will be removed in the future versions as it is already deprecated.
1 parent 360d473 commit 5854959

File tree

142 files changed

+581
-279
lines changed

Some content is hidden

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

142 files changed

+581
-279
lines changed
Submodule Equal updated 1 file
Submodule Log updated 1 file
Submodule Lucre updated 1 file
Submodule Model updated 1 file
Submodule Serial updated 1 file
Submodule Span updated 1 file
Submodule fs2 updated 1 file
Submodule scodec updated 1 file
Submodule verify updated 1 file

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

+9-10
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ final case class SbtCommunityProject(
149149
object SbtCommunityProject:
150150
def scalacOptions = List(
151151
"-Xcheck-macros",
152-
"-Ysafe-init",
152+
"-Wsafe-init",
153153
)
154154

155155
object projects:
@@ -362,7 +362,7 @@ object projects:
362362
project = "shapeless-3",
363363
sbtTestCommand = "testJVM; testJS",
364364
sbtDocCommand = forceDoc("typeable", "deriving"),
365-
scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), // due to -Xfatal-warnings
365+
scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"), // due to -Xfatal-warnings
366366
)
367367

368368
lazy val xmlInterpolator = SbtCommunityProject(
@@ -429,7 +429,7 @@ object projects:
429429
sbtTestCommand = "unitTests/test",
430430
// Adds <empty> package
431431
sbtDocCommand = "coreJVM/doc",
432-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
432+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
433433
dependencies = List(munit, scodecBits),
434434
)
435435

@@ -510,7 +510,7 @@ object projects:
510510
project = "discipline",
511511
sbtTestCommand = "coreJVM/test;coreJS/test",
512512
sbtPublishCommand = "set every credentials := Nil;coreJVM/publishLocal;coreJS/publishLocal",
513-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
513+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
514514
dependencies = List(scalacheck)
515515
)
516516

@@ -526,7 +526,7 @@ object projects:
526526
sbtTestCommand = "test",
527527
sbtPublishCommand = "coreJVM/publishLocal;coreJS/publishLocal",
528528
dependencies = List(discipline),
529-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init")
529+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init")
530530
)
531531

532532
lazy val simulacrumScalafixAnnotations = SbtCommunityProject(
@@ -540,8 +540,7 @@ object projects:
540540
sbtTestCommand = "set Global/scalaJSStage := FastOptStage;rootJVM/test;rootJS/test",
541541
sbtPublishCommand = "rootJVM/publishLocal;rootJS/publishLocal",
542542
dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations),
543-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init") // disable -Ysafe-init, due to -Xfatal-warning
544-
543+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init") // disable -Ysafe-init or -Wsafe-init, due to -Xfatal-warning
545544
)
546545

547546
lazy val catsMtl = SbtCommunityProject(
@@ -656,7 +655,7 @@ object projects:
656655
"""set actorTests/Compile/scalacOptions -= "-Xfatal-warnings"""",
657656
"akka-actor-tests/Test/compile",
658657
).mkString("; "),
659-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
658+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
660659
dependencies = List(scalatest, scalatestplusJunit, scalatestplusScalacheck)
661660
)
662661

@@ -707,7 +706,7 @@ object projects:
707706
project = "fs2",
708707
sbtTestCommand = "coreJVM/test; coreJS/test", // io/test requires JDK9+
709708
sbtPublishCommand = "coreJVM/publishLocal; coreJS/publishLocal",
710-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
709+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
711710
dependencies = List(cats, catsEffect3, munitCatsEffect, scalacheckEffect, scodecBits)
712711
)
713712

@@ -744,7 +743,7 @@ object projects:
744743
project = "http4s",
745744
sbtTestCommand = """set ThisBuild / tlFatalWarnings := false; rootJVM/test""",
746745
sbtPublishCommand = "publishLocal",
747-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
746+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
748747
dependencies = List(cats, catsEffect3, fs2, disciplineMunit, scalacheckEffect)
749748
)
750749

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ trait BCodeHelpers extends BCodeIdiomatic {
823823
// without it. This is particularly bad because the availability of
824824
// generic information could disappear as a consequence of a seemingly
825825
// unrelated change.
826-
ctx.base.settings.YnoGenericSig.value
826+
ctx.base.settings.XnoGenericSig.value
827827
|| sym.is(Artifact)
828828
|| sym.isAllOf(LiftedMethod)
829829
|| sym.is(Bridge)

compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ object PostProcessorFrontendAccess {
121121
case (None, None) => "8" // least supported version by default
122122

123123
override val debug: Boolean = ctx.debug
124-
override val dumpClassesDirectory: Option[String] = s.Ydumpclasses.valueSetByUser
124+
override val dumpClassesDirectory: Option[String] = s.Xdumpclasses.valueSetByUser
125125
override val outputDirectory: AbstractFile = s.outputDir.value
126126
override val mainClass: Option[String] = s.XmainClass.valueSetByUser
127-
override val jarCompressionLevel: Int = s.YjarCompressionLevel.value
127+
override val jarCompressionLevel: Int = s.XjarCompressionLevel.value
128128
override val backendParallelism: Int = s.YbackendParallelism.value
129129
override val backendMaxWorkerQueue: Option[Int] = s.YbackendWorkerQueue.valueSetByUser
130+
131+
@annotation.nowarn("cat=deprecation")
130132
override val outputOnlyTasty: Boolean = s.YoutputOnlyTasty.value
131133
}
132134

compiler/src/dotty/tools/dotc/Driver.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Driver {
8484
Positioned.init(using ictx)
8585

8686
inContext(ictx) {
87-
if !ctx.settings.YdropComments.value || ctx.settings.YreadComments.value then
87+
if !ctx.settings.XdropComments.value || ctx.settings.XreadComments.value then
8888
ictx.setProperty(ContextDoc, new ContextDocstrings)
8989
val fileNamesOrNone = command.checkUsage(summary, sourcesRequired)(using ctx.settings)(using ctx.settingsState)
9090
fileNamesOrNone.map { fileNames =>

compiler/src/dotty/tools/dotc/Run.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
377377
runCtx.withProgressCallback: cb =>
378378
_progress = Progress(cb, this, fusedPhases.map(_.traversals).sum)
379379
val cancelAsyncTasty: () => Unit =
380-
if !myAsyncTastyWritten && Phases.picklerPhase.exists && !ctx.settings.YearlyTastyOutput.isDefault then
380+
if !myAsyncTastyWritten && Phases.picklerPhase.exists && !ctx.settings.XearlyTastyOutput.isDefault then
381381
initializeAsyncTasty()
382382
else () => {}
383383

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ trait CliCommand:
6060
def defaultValue = s.default match
6161
case _: Int | _: String => s.default.toString
6262
case _ => ""
63-
val info = List(shortHelp(s), if defaultValue.nonEmpty then s"Default $defaultValue" else "", if s.legalChoices.nonEmpty then s"Choices : ${s.legalChoices}" else "")
63+
val deprecationMessage = s.deprecation.map(d => s"Option deprecated.\n${d.msg}").getOrElse("")
64+
val info = List(deprecationMessage, shortHelp(s), if defaultValue.nonEmpty then s"Default $defaultValue" else "", if s.legalChoices.nonEmpty then s"Choices : ${s.legalChoices}" else "")
6465
(s.name, info.filter(_.nonEmpty).mkString("\n"))
6566
end help
6667

0 commit comments

Comments
 (0)