diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 30c1784e442a..1c02e8fcf6b5 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -112,7 +112,8 @@ trait Warnings { ) ) withAbbreviation "-Ywarn-macros" val warnDeadCode = BooleanSetting("-Wdead-code", "Warn when dead code is identified.") withAbbreviation "-Ywarn-dead-code" - val warnValueDiscard = BooleanSetting("-Wvalue-discard", "Warn when non-Unit expression results are unused.") withAbbreviation "-Ywarn-value-discard" + @deprecated("Use lintValueDiscard", since="2.13.3") + val warnValueDiscard = BooleanSetting("-Wvalue-discard", "Warn when non-Unit expression results are unused.") withAbbreviation "-Ywarn-value-discard" withDeprecationMessage "Use -Xlint:value-discard" val warnNumericWiden = BooleanSetting("-Wnumeric-widen", "Warn when numerics are widened.") withAbbreviation "-Ywarn-numeric-widen" val warnOctalLiteral = BooleanSetting("-Woctal-literal", "Warn on obsolete octal syntax.") withAbbreviation "-Ywarn-octal-literal" @@ -149,7 +150,7 @@ trait Warnings { val warnExtraImplicit = BooleanSetting("-Wextra-implicit", "Warn when more than one implicit parameter section is defined.") withAbbreviation "-Ywarn-extra-implicit" @deprecated("Use lintImplicitRecursion", since="2.13.3") - val warnSelfImplicit = BooleanSetting("-Wself-implicit", "An implicit resolves to an enclosing definition.") withAbbreviation "-Ywarn-self-implicit" withDeprecationMessage "Use -Xlint:implicit-recurses" + val warnSelfImplicit = BooleanSetting("-Wself-implicit", "An implicit resolves to an enclosing definition.") withAbbreviation "-Ywarn-self-implicit" withDeprecationMessage "Use -Xlint:implicit-recursion" // Experimental lint warnings that are turned off, but which could be turned on programmatically. // They are not activated by -Xlint and can't be enabled on the command line because they are not @@ -194,7 +195,8 @@ trait Warnings { val RecurseWithDefault = LintWarning("recurse-with-default", "Recursive call used default argument.") val UnitSpecialization = LintWarning("unit-special", "Warn for specialization of Unit in parameter position.") val MultiargInfix = LintWarning("multiarg-infix", "Infix operator was defined or used with multiarg operand.") - val ImplicitRecurses = LintWarning("implicit-recurses", "Implicit resolves to an enclosing definition.") + val ImplicitRecursion = LintWarning("implicit-recursion", "Implicit resolves to an enclosing definition.") + val ValueDiscard = LintWarning("value-discard", "A non-Unit value was not used because Unit was required.") def allLintWarnings = values.toSeq.asInstanceOf[Seq[LintWarning]] } @@ -227,7 +229,8 @@ trait Warnings { def warnRecurseWithDefault = lint contains RecurseWithDefault def unitSpecialization = lint contains UnitSpecialization def multiargInfix = lint contains MultiargInfix - def lintImplicitRecursion = lint.contains(ImplicitRecurses) || warnSelfImplicit + def lintImplicitRecursion = lint.contains(ImplicitRecursion) || warnSelfImplicit + def lintValueDiscard = lint.contains(ValueDiscard) || warnValueDiscard // The Xlint warning group. val lint = MultiChoiceSetting( diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index e014e4832587..e7de6e73bd7d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1144,7 +1144,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper @inline def tpdPos(transformed: Tree) = typedPos(tree.pos, mode, pt)(transformed) @inline def tpd(transformed: Tree) = typed(transformed, mode, pt) - @inline def warnValueDiscard(): Unit = if (!isPastTyper && settings.warnValueDiscard) { + @inline def warnValueDiscard(): Unit = if (!isPastTyper && settings.lintValueDiscard) { def isThisTypeResult = (tree, tree.tpe) match { case (Apply(Select(receiver, _), _), SingleType(_, sym)) => sym == receiver.symbol case _ => false diff --git a/test/files/neg/implicitly-self.scala b/test/files/neg/implicitly-self.scala index ca1ceb807b6a..8515f1235d23 100644 --- a/test/files/neg/implicitly-self.scala +++ b/test/files/neg/implicitly-self.scala @@ -1,4 +1,4 @@ -// scalac: -Werror -Xlint:implicit-recurses +// scalac: -Werror -Xlint:implicit-recursion // trait TC[A] { def ix: Int } diff --git a/test/files/pos/t11813.scala b/test/files/pos/t11813.scala index b0953d6df3e3..0e827625c690 100644 --- a/test/files/pos/t11813.scala +++ b/test/files/pos/t11813.scala @@ -1,4 +1,4 @@ -// scalac: -Werror -Xlint:implicit-recurses +// scalac: -Werror -Xlint:implicit-recursion // package warner