Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune Scala compiler warnings #344

Merged
merged 4 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kernel/src/main/scala/org/typelevel/sbt/kernel/V.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ private[sbt] final case class V(
if (y != 0) return y
(this.patch, that.patch) match {
case (None, None) => 0
case (None, Some(patch)) => 1
case (Some(patch), None) => -1
case (None, Some(_)) => 1
case (Some(_), None) => -1
case (Some(thisPatch), Some(thatPatch)) =>
val z = thisPatch.compare(thatPatch)
if (z != 0) return z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,31 @@ object TypelevelSettingsPlugin extends AutoPlugin {
}
},
scalacOptions ++= {
val warningsNsc = Seq("-Xlint", "-Ywarn-dead-code")
val warningsNsc = Seq(
"-Xlint",
"-Ywarn-dead-code"
)

val warnings211 =
Seq("-Ywarn-numeric-widen") // In 2.10 this produces a some strange spurious error
val warnings211 = Seq(
"-Ywarn-numeric-widen" // In 2.10 this produces a some strange spurious error
)

val warnings212 = Seq.empty[String]
val removed212 = Set(
"-Xlint"
)
val warnings212 = Seq(
// Tune '-Xlint':
// - remove 'unused' because it is configured by '-Ywarn-unused'
"-Xlint:_,-unused",
// Tune '-Ywarn-unused':
// - remove 'nowarn' because 2.13 can detect more unused cases than 2.12
// - remove 'privates' because 2.12 can incorrectly detect some private objects as unused
"-Ywarn-unused:_,-nowarn,-privates"
)

val removed213 = Set(
"-Xlint",
"-Xlint:_,-unused", // reconfigured for 2.13
"-Ywarn-unused:_,-nowarn,-privates", // mostly superseded by "-Wunused"
"-Ywarn-dead-code", // superseded by "-Wdead-code"
"-Ywarn-numeric-widen" // superseded by "-Wnumeric-widen"
)
Expand All @@ -98,7 +114,11 @@ object TypelevelSettingsPlugin extends AutoPlugin {
"-Wnumeric-widen",
"-Wunused", // all choices are enabled by default
"-Wvalue-discard",
"-Xlint:deprecation"
// Tune '-Xlint':
// - remove 'implicit-recursion' due to backward incompatibility with 2.12
// - remove 'recurse-with-default' due to backward incompatibility with 2.12
// - remove 'unused' because it is configured by '-Wunused'
"-Xlint:_,-implicit-recursion,-recurse-with-default,-unused"
)

val warningsDotty = Seq.empty
Expand All @@ -108,10 +128,11 @@ object TypelevelSettingsPlugin extends AutoPlugin {
warningsDotty

case V(V(2, minor, _, _)) if minor >= 13 =>
(warnings211 ++ warnings212 ++ warnings213 ++ warningsNsc).filterNot(removed213)
(warnings211 ++ warnings212 ++ warnings213 ++ warningsNsc)
.filterNot(removed212 ++ removed213)

case V(V(2, minor, _, _)) if minor >= 12 =>
warnings211 ++ warnings212 ++ warningsNsc
(warnings211 ++ warnings212 ++ warningsNsc).filterNot(removed212)

case V(V(2, minor, _, _)) if minor >= 11 =>
warnings211 ++ warningsNsc
Expand Down