diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-12-20 14:35:43 -0800 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2017-03-11 23:48:32 -0800 |
commit | 785f4fe224302bbddbbd6a198f1722b4c0ae17f7 (patch) | |
tree | 6b040f5c2b5318bff7c0077c0d9719165e388d9f /src/compiler/scala/tools/nsc/settings/Warnings.scala | |
parent | 6d7b81a1e47960fbbc469108a34414f76a706342 (diff) | |
download | scala-785f4fe224302bbddbbd6a198f1722b4c0ae17f7.tar.gz scala-785f4fe224302bbddbbd6a198f1722b4c0ae17f7.tar.bz2 scala-785f4fe224302bbddbbd6a198f1722b4c0ae17f7.zip |
SI-8040 Xlint enables unused warnings
`-Ywarn-unused-import` is deprecated in favor of `-Ywarn-unused:imports`.
`-Xlint` does not yet enable `-Ywarn-unused:patvars`.
But the default for `-Ywarn-unused` is everything, including `patvars`.
So `-Xlint:unused` is the populist option, `-Ywarn-unused` more exclusive.
Tests are fixed by narrowing scope of `-Xlint` when specified.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/Warnings.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/Warnings.scala | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 29138c78d1..eb78064155 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -48,7 +48,7 @@ trait Warnings { BooleanSetting("-Ywarn-unused-import", "Warn when imports are unused.") withPostSetHook { s => warnUnused.add(s"${if (s) "" else "-"}imports") - } // withDeprecationMessage s"Enable -Ywarn-unused:imports" + } withDeprecationMessage s"Enable -Ywarn-unused:imports" val warnExtraImplicit = BooleanSetting("-Ywarn-extra-implicit", "Warn when more than one implicit parameter section is defined.") @@ -85,8 +85,7 @@ trait Warnings { val UnsoundMatch = LintWarning("unsound-match", "Pattern match may not be typesafe.") val StarsAlign = LintWarning("stars-align", "Pattern sequence wildcard must align with sequence component.") val Constant = LintWarning("constant", "Evaluation of a constant arithmetic expression results in an error.") - //val Unused = LintWarning("unused", "Warn when private and local definitions are unused.") - val Unused = LintWarning("unused", "Use -Ywarn-unused to warn when private and local definitions are unused.") + val Unused = LintWarning("unused", "Enable -Ywarn-unused:-patvars,_.") def allLintWarnings = values.toSeq.asInstanceOf[Seq[LintWarning]] } @@ -129,9 +128,8 @@ trait Warnings { helpArg = "warning", descr = "Enable or disable specific warnings", domain = LintWarnings, - default = Some(List("_"))) //.withPostSetHook (s => if (s contains Unused) warnUnused.add("_")) - - // restore -Xlint:unused hook when SI-8040 is complete + default = Some(List("_")) + ).withPostSetHook { s => if (s contains Unused) List("-patvars","_").foreach(warnUnused.add) } allLintWarnings foreach { case w if w.yAliased => |