Skip to content

Commit

Permalink
Lift Scala Settings from experimental to stabilized (#20199)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rochala authored May 7, 2024
1 parent 360d473 commit 5854959
Show file tree
Hide file tree
Showing 142 changed files with 581 additions and 279 deletions.
2 changes: 1 addition & 1 deletion community-build/community-projects/AsyncFile
Submodule AsyncFile updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/Equal
Submodule Equal updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/FingerTree
Submodule FingerTree updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/Log
Submodule Log updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/Lucre
Submodule Lucre updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/Model
Submodule Model updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/Numbers
Submodule Numbers updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/Serial
Submodule Serial updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/Span
Submodule Span updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/discipline
Submodule discipline updated 1 files
+2 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/discipline-munit
Submodule discipline-munit updated 1 files
+2 −0 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/discipline-specs2
Submodule discipline-specs2 updated 1 files
+2 −0 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/fs2
Submodule fs2 updated 1 files
+2 −0 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/scala-stm
Submodule scala-stm updated 1 files
+1 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/scodec
Submodule scodec updated 1 files
+5 −1 build.sbt
2 changes: 1 addition & 1 deletion community-build/community-projects/verify
Submodule verify updated 1 files
+0 −1 build.sbt
19 changes: 9 additions & 10 deletions community-build/src/scala/dotty/communitybuild/projects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ final case class SbtCommunityProject(
object SbtCommunityProject:
def scalacOptions = List(
"-Xcheck-macros",
"-Ysafe-init",
"-Wsafe-init",
)

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

lazy val xmlInterpolator = SbtCommunityProject(
Expand Down Expand Up @@ -429,7 +429,7 @@ object projects:
sbtTestCommand = "unitTests/test",
// Adds <empty> package
sbtDocCommand = "coreJVM/doc",
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
dependencies = List(munit, scodecBits),
)

Expand Down Expand Up @@ -510,7 +510,7 @@ object projects:
project = "discipline",
sbtTestCommand = "coreJVM/test;coreJS/test",
sbtPublishCommand = "set every credentials := Nil;coreJVM/publishLocal;coreJS/publishLocal",
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
dependencies = List(scalacheck)
)

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

lazy val simulacrumScalafixAnnotations = SbtCommunityProject(
Expand All @@ -540,8 +540,7 @@ object projects:
sbtTestCommand = "set Global/scalaJSStage := FastOptStage;rootJVM/test;rootJS/test",
sbtPublishCommand = "rootJVM/publishLocal;rootJS/publishLocal",
dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init") // disable -Ysafe-init, due to -Xfatal-warning

scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init") // disable -Ysafe-init or -Wsafe-init, due to -Xfatal-warning
)

lazy val catsMtl = SbtCommunityProject(
Expand Down Expand Up @@ -656,7 +655,7 @@ object projects:
"""set actorTests/Compile/scalacOptions -= "-Xfatal-warnings"""",
"akka-actor-tests/Test/compile",
).mkString("; "),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
dependencies = List(scalatest, scalatestplusJunit, scalatestplusScalacheck)
)

Expand Down Expand Up @@ -707,7 +706,7 @@ object projects:
project = "fs2",
sbtTestCommand = "coreJVM/test; coreJS/test", // io/test requires JDK9+
sbtPublishCommand = "coreJVM/publishLocal; coreJS/publishLocal",
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
dependencies = List(cats, catsEffect3, munitCatsEffect, scalacheckEffect, scodecBits)
)

Expand Down Expand Up @@ -744,7 +743,7 @@ object projects:
project = "http4s",
sbtTestCommand = """set ThisBuild / tlFatalWarnings := false; rootJVM/test""",
sbtPublishCommand = "publishLocal",
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"),
dependencies = List(cats, catsEffect3, fs2, disciplineMunit, scalacheckEffect)
)

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ trait BCodeHelpers extends BCodeIdiomatic {
// without it. This is particularly bad because the availability of
// generic information could disappear as a consequence of a seemingly
// unrelated change.
ctx.base.settings.YnoGenericSig.value
ctx.base.settings.XnoGenericSig.value
|| sym.is(Artifact)
|| sym.isAllOf(LiftedMethod)
|| sym.is(Bridge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ object PostProcessorFrontendAccess {
case (None, None) => "8" // least supported version by default

override val debug: Boolean = ctx.debug
override val dumpClassesDirectory: Option[String] = s.Ydumpclasses.valueSetByUser
override val dumpClassesDirectory: Option[String] = s.Xdumpclasses.valueSetByUser
override val outputDirectory: AbstractFile = s.outputDir.value
override val mainClass: Option[String] = s.XmainClass.valueSetByUser
override val jarCompressionLevel: Int = s.YjarCompressionLevel.value
override val jarCompressionLevel: Int = s.XjarCompressionLevel.value
override val backendParallelism: Int = s.YbackendParallelism.value
override val backendMaxWorkerQueue: Option[Int] = s.YbackendWorkerQueue.valueSetByUser

@annotation.nowarn("cat=deprecation")
override val outputOnlyTasty: Boolean = s.YoutputOnlyTasty.value
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Driver {
Positioned.init(using ictx)

inContext(ictx) {
if !ctx.settings.YdropComments.value || ctx.settings.YreadComments.value then
if !ctx.settings.XdropComments.value || ctx.settings.XreadComments.value then
ictx.setProperty(ContextDoc, new ContextDocstrings)
val fileNamesOrNone = command.checkUsage(summary, sourcesRequired)(using ctx.settings)(using ctx.settingsState)
fileNamesOrNone.map { fileNames =>
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
runCtx.withProgressCallback: cb =>
_progress = Progress(cb, this, fusedPhases.map(_.traversals).sum)
val cancelAsyncTasty: () => Unit =
if !myAsyncTastyWritten && Phases.picklerPhase.exists && !ctx.settings.YearlyTastyOutput.isDefault then
if !myAsyncTastyWritten && Phases.picklerPhase.exists && !ctx.settings.XearlyTastyOutput.isDefault then
initializeAsyncTasty()
else () => {}

Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/config/CliCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ trait CliCommand:
def defaultValue = s.default match
case _: Int | _: String => s.default.toString
case _ => ""
val info = List(shortHelp(s), if defaultValue.nonEmpty then s"Default $defaultValue" else "", if s.legalChoices.nonEmpty then s"Choices : ${s.legalChoices}" else "")
val deprecationMessage = s.deprecation.map(d => s"Option deprecated.\n${d.msg}").getOrElse("")
val info = List(deprecationMessage, shortHelp(s), if defaultValue.nonEmpty then s"Default $defaultValue" else "", if s.legalChoices.nonEmpty then s"Choices : ${s.legalChoices}" else "")
(s.name, info.filter(_.nonEmpty).mkString("\n"))
end help

Expand Down
Loading

0 comments on commit 5854959

Please sign in to comment.