summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/settings/Warnings.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-07-01 08:21:07 -0700
committerSom Snytt <som.snytt@gmail.com>2014-07-10 09:27:51 -0700
commit3b89c168b4926139f7295183fdc1903f6f553798 (patch)
tree640f0672a1deadf6d3b7e57383be6432165a551f /src/compiler/scala/tools/nsc/settings/Warnings.scala
parent44855dcd3c2e19d5dbaf01b2165ea8dc9fb287d3 (diff)
downloadscala-3b89c168b4926139f7295183fdc1903f6f553798.tar.gz
scala-3b89c168b4926139f7295183fdc1903f6f553798.tar.bz2
scala-3b89c168b4926139f7295183fdc1903f6f553798.zip
SI-8525 No anonymous lint
Turn anonymous references to `settings.lint` into named settings. After that, trust to Adriaan to make them filterable. There are a few remaining top-level -Y lint warnings that are deprecated.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/Warnings.scala')
-rw-r--r--src/compiler/scala/tools/nsc/settings/Warnings.scala97
1 files changed, 81 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala
index f1ed45a2a0..3ff2369f86 100644
--- a/src/compiler/scala/tools/nsc/settings/Warnings.scala
+++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala
@@ -34,34 +34,76 @@ trait Warnings {
warnInferAny,
// warnUnused SI-7712, SI-7707 warnUnused not quite ready for prime-time
// warnUnusedImport currently considered too noisy for general use
- warnMissingInterpolator
+ // warnValueOverrides
+ warnMissingInterpolator,
+ warnDocDetached,
+ warnPrivateShadow,
+ warnPolyImplicitOverload,
+ warnOptionImplicit,
+ warnDelayedInit,
+ warnByNameRightAssociative,
+ warnPackageObjectClasses,
+ warnUnsoundMatch
)
private lazy val warnSelectNullable = BooleanSetting("-Xcheck-null", "This option is obsolete and does nothing.")
// Individual warnings.
- val warnAdaptedArgs = BooleanSetting ("-Ywarn-adapted-args", "Warn if an argument list is modified to match the receiver.")
- val warnDeadCode = BooleanSetting ("-Ywarn-dead-code", "Warn when dead code is identified.")
- val warnValueDiscard = BooleanSetting ("-Ywarn-value-discard", "Warn when non-Unit expression results are unused.")
- val warnNumericWiden = BooleanSetting ("-Ywarn-numeric-widen", "Warn when numerics are widened.")
- val warnNullaryUnit = BooleanSetting ("-Ywarn-nullary-unit", "Warn when nullary methods return Unit.")
- val warnInaccessible = BooleanSetting ("-Ywarn-inaccessible", "Warn about inaccessible types in method signatures.")
- val warnNullaryOverride = BooleanSetting ("-Ywarn-nullary-override", "Warn when non-nullary overrides nullary, e.g. `def foo()` over `def foo`.")
- val warnInferAny = BooleanSetting ("-Ywarn-infer-any", "Warn when a type argument is inferred to be `Any`.")
- val warnUnused = BooleanSetting ("-Ywarn-unused", "Warn when local and private vals, vars, defs, and types are are unused")
- val warnUnusedImport = BooleanSetting ("-Ywarn-unused-import", "Warn when imports are unused")
+ val warnDeadCode = BooleanSetting("-Ywarn-dead-code",
+ "Warn when dead code is identified.")
+ val warnValueDiscard = BooleanSetting("-Ywarn-value-discard",
+ "Warn when non-Unit expression results are unused.")
+ val warnNumericWiden = BooleanSetting("-Ywarn-numeric-widen",
+ "Warn when numerics are widened.")
+ val warnUnused = BooleanSetting("-Ywarn-unused",
+ "Warn when local and private vals, vars, defs, and types are are unused")
+ val warnUnusedImport = BooleanSetting("-Ywarn-unused-import",
+ "Warn when imports are unused")
- // Lint warnings that are not -Y
- val warnMissingInterpolator = new BooleanSetting("warn-missing-interpolator", "Warn when a string literal appears to be missing an interpolator id.")
+ // Lint warnings that are not -Y, created with new instead of autoregistering factory method
+ private def lintflag(name: String, text: String) = new BooleanSetting(name, text)
+
+ val warnAdaptedArgs = lintflag("adapted-args",
+ "Warn if an argument list is modified to match the receiver.")
+ val warnNullaryUnit = lintflag("nullary-unit",
+ "Warn when nullary methods return Unit.")
+ val warnInaccessible = lintflag("inaccessible",
+ "Warn about inaccessible types in method signatures.")
+ val warnNullaryOverride = lintflag("nullary-override",
+ "Warn when non-nullary `def f()' overrides nullary `def f'.")
+ val warnInferAny = lintflag("infer-any",
+ "Warn when a type argument is inferred to be `Any`.")
+ val warnMissingInterpolator = lintflag("missing-interpolator",
+ "A string literal appears to be missing an interpolator id.")
+ val warnDocDetached = lintflag("doc-detached",
+ "A ScalaDoc comment appears to be detached from its element.")
+ val warnPrivateShadow = lintflag("private-shadow",
+ "A private field (or class parameter) shadows a superclass field.")
+ val warnPolyImplicitOverload = lintflag("poly-implicit-overload",
+ "Parameterized overloaded implicit methods are not visible as view bounds")
+ val warnOptionImplicit = lintflag("option-implicit",
+ "Option.apply used implicit view.")
+ val warnDelayedInit = lintflag("delayedinit-select",
+ "Selecting member of DelayedInit")
+ val warnByNameRightAssociative = lintflag("by-name-right-associative",
+ "By-name parameter of right associative operator")
+ val warnPackageObjectClasses = lintflag("package-object-classes",
+ "Class or object defined in package object")
+ val warnUnsoundMatch = lintflag("unsound-match",
+ "Pattern match may not be typesafe")
+
+ // Lint warnings that are not enabled yet
+ val warnValueOverrides = lintflag("value-overrides", "Generated value class method overrides an implementation")
// Warning groups.
val lint = {
// Boolean setting for testing if lint is on; not "added" to option processing
- val xlint = new BooleanSetting("-Xlint", "Enable recommended additional warnings.")
- def lintables = (lintWarnings map (_.name stripPrefix "-Y")).sorted
+ val xlint = lintflag("-Xlint", "Enable recommended additional warnings.")
+ val yprefix = "-Ywarn-"
+ def lintables = (lintWarnings map (_.name stripPrefix yprefix)).sorted
def isAnon(b: BooleanSetting) = !(b.name startsWith "-")
def setPolitely(b: BooleanSetting, v: Boolean) = if (!b.isSetByUser) b.value = v
- def set(w: String, v: Boolean) = lintWarnings find (_.name.stripPrefix("-Y") == w) foreach (b => setPolitely(b, v))
+ def set(w: String, v: Boolean) = lintWarnings find (s => (s.name stripPrefix yprefix) == w) foreach (b => setPolitely(b, v))
val Neg = "-"
def propagate(ss: List[String]): Unit = ss match {
case w :: rest => if (w startsWith Neg) set(w stripPrefix Neg, false) else set(w, true) ; propagate(rest)
@@ -81,6 +123,29 @@ trait Warnings {
xlint
}
+ // Lint warnings that are currently -Y, but deprecated in that usage
+ // Alas, the -Yarg must have a doppelgaenger that is not deprecated
+ @deprecated("Use the Xlint flag", since="2.11.2")
+ val YwarnAdaptedArgs = BooleanSetting("-Ywarn-adapted-args",
+ "Warn if an argument list is modified to match the receiver.") withDeprecationMessage
+ "Enable -Xlint:adapted-args" enabling List(warnAdaptedArgs)
+ @deprecated("Use the Xlint flag", since="2.11.2")
+ val YwarnNullaryUnit = BooleanSetting("-Ywarn-nullary-unit",
+ "Warn when nullary methods return Unit.") withDeprecationMessage
+ "Enable -Xlint:nullary-unit" enabling List(warnNullaryUnit)
+ @deprecated("Use the Xlint flag", since="2.11.2")
+ val YwarnInaccessible = BooleanSetting("-Ywarn-inaccessible",
+ "Warn about inaccessible types in method signatures.") withDeprecationMessage
+ "Enable -Xlint:inaccessible" enabling List(warnInaccessible)
+ @deprecated("Use the Xlint flag", since="2.11.2")
+ val YwarnNullaryOverride = BooleanSetting("-Ywarn-nullary-override",
+ "Warn when non-nullary `def f()' overrides nullary `def f'.") withDeprecationMessage
+ "Enable -Xlint:nullary-override" enabling List(warnNullaryOverride)
+ @deprecated("Use the Xlint flag", since="2.11.2")
+ val YwarnInferAny = BooleanSetting("-Ywarn-infer-any",
+ "Warn when a type argument is inferred to be `Any`.") withDeprecationMessage
+ "Enable -Xlint:infer-any" enabling List(warnInferAny)
+
// Backward compatibility.
@deprecated("Use fatalWarnings", "2.11.0") def Xwarnfatal = fatalWarnings // used by sbt
@deprecated("This option is being removed", "2.11.0") def Xchecknull = warnSelectNullable // used by ide