From dab82c681007f3c17f0b69e1498b1133113d7cc5 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Mon, 17 Jul 2023 17:34:28 -0700 Subject: [PATCH] Remove deprecated advice --- .../tools/nsc/typechecker/RefChecks.scala | 2 +- test/files/neg/nonunit-if.check | 30 +++++++++---------- test/files/neg/nonunit-statement.check | 22 +++++++------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 0c7bde2ce48b..e6d54d6d4763 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1896,7 +1896,7 @@ abstract class RefChecks extends Transform { } case _ => t } - def msg = s"unused value of type ${where.tpe} (add `: Unit` to discard silently)" + def msg = s"unused value of type ${where.tpe}" refchecksWarning(where.pos, msg, WarningCategory.OtherPureStatement) true } diff --git a/test/files/neg/nonunit-if.check b/test/files/neg/nonunit-if.check index d1ffb1337ef3..4d7726452c55 100644 --- a/test/files/neg/nonunit-if.check +++ b/test/files/neg/nonunit-if.check @@ -4,52 +4,52 @@ nonunit-if.scala:58: warning: discarded non-Unit value of type U nonunit-if.scala:62: warning: discarded non-Unit value of type Boolean f(a) // warn, check is on ^ -nonunit-if.scala:13: warning: unused value of type scala.concurrent.Future[Int] (add `: Unit` to discard silently) +nonunit-if.scala:13: warning: unused value of type scala.concurrent.Future[Int] improved // warn ^ -nonunit-if.scala:20: warning: unused value of type String (add `: Unit` to discard silently) +nonunit-if.scala:20: warning: unused value of type String new E().toString // warn ^ -nonunit-if.scala:26: warning: unused value of type scala.concurrent.Future[Int] (add `: Unit` to discard silently) +nonunit-if.scala:26: warning: unused value of type scala.concurrent.Future[Int] Future(42) // warn ^ -nonunit-if.scala:30: warning: unused value of type K (add `: Unit` to discard silently) +nonunit-if.scala:30: warning: unused value of type K copy() // warn ^ -nonunit-if.scala:37: warning: unused value of type List[Int] (add `: Unit` to discard silently) +nonunit-if.scala:37: warning: unused value of type List[Int] 27 +: xs // warn ^ nonunit-if.scala:44: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses null // warn for purity ^ -nonunit-if.scala:58: warning: unused value of type U (add `: Unit` to discard silently) +nonunit-if.scala:58: warning: unused value of type U if (!isEmpty) f(a) // warn, check is on ^ -nonunit-if.scala:62: warning: unused value of type Boolean (add `: Unit` to discard silently) +nonunit-if.scala:62: warning: unused value of type Boolean f(a) // warn, check is on ^ -nonunit-if.scala:73: warning: unused value of type U (add `: Unit` to discard silently) +nonunit-if.scala:73: warning: unused value of type U if (!fellback) action(z) // warn, check is on ^ -nonunit-if.scala:81: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-if.scala:81: warning: unused value of type Int g // warn, check is on ^ -nonunit-if.scala:79: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-if.scala:79: warning: unused value of type Int g // warn block statement ^ -nonunit-if.scala:86: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-if.scala:86: warning: unused value of type Int g // warn ^ -nonunit-if.scala:84: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-if.scala:84: warning: unused value of type Int g // warn ^ -nonunit-if.scala:96: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-if.scala:96: warning: unused value of type Int if (b) { // warn, at least one branch looks interesting ^ -nonunit-if.scala:116: warning: unused value of type scala.collection.mutable.LinkedHashSet[A] (add `: Unit` to discard silently) +nonunit-if.scala:116: warning: unused value of type scala.collection.mutable.LinkedHashSet[A] set += a // warn because cannot know whether the `set` was supposed to be consumed or assigned ^ -nonunit-if.scala:146: warning: unused value of type String (add `: Unit` to discard silently) +nonunit-if.scala:146: warning: unused value of type String while (it.hasNext) it.next() // warn ^ error: No warnings can be incurred under -Werror. diff --git a/test/files/neg/nonunit-statement.check b/test/files/neg/nonunit-statement.check index b15ae34fb7fd..f5fc17a63526 100644 --- a/test/files/neg/nonunit-statement.check +++ b/test/files/neg/nonunit-statement.check @@ -1,37 +1,37 @@ -nonunit-statement.scala:13: warning: unused value of type scala.concurrent.Future[Int] (add `: Unit` to discard silently) +nonunit-statement.scala:13: warning: unused value of type scala.concurrent.Future[Int] improved // warn ^ -nonunit-statement.scala:20: warning: unused value of type String (add `: Unit` to discard silently) +nonunit-statement.scala:20: warning: unused value of type String new E().toString // warn ^ -nonunit-statement.scala:26: warning: unused value of type scala.concurrent.Future[Int] (add `: Unit` to discard silently) +nonunit-statement.scala:26: warning: unused value of type scala.concurrent.Future[Int] Future(42) // warn ^ -nonunit-statement.scala:30: warning: unused value of type K (add `: Unit` to discard silently) +nonunit-statement.scala:30: warning: unused value of type K copy() // warn ^ -nonunit-statement.scala:37: warning: unused value of type List[Int] (add `: Unit` to discard silently) +nonunit-statement.scala:37: warning: unused value of type List[Int] 27 +: xs // warn ^ nonunit-statement.scala:44: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses null // warn for purity ^ -nonunit-statement.scala:79: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-statement.scala:79: warning: unused value of type Int g // warn block statement ^ -nonunit-statement.scala:86: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-statement.scala:86: warning: unused value of type Int g // warn ^ -nonunit-statement.scala:84: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-statement.scala:84: warning: unused value of type Int g // warn ^ -nonunit-statement.scala:96: warning: unused value of type Int (add `: Unit` to discard silently) +nonunit-statement.scala:96: warning: unused value of type Int if (b) { // warn, at least one branch looks interesting ^ -nonunit-statement.scala:116: warning: unused value of type scala.collection.mutable.LinkedHashSet[A] (add `: Unit` to discard silently) +nonunit-statement.scala:116: warning: unused value of type scala.collection.mutable.LinkedHashSet[A] set += a // warn because cannot know whether the `set` was supposed to be consumed or assigned ^ -nonunit-statement.scala:146: warning: unused value of type String (add `: Unit` to discard silently) +nonunit-statement.scala:146: warning: unused value of type String while (it.hasNext) it.next() // warn ^ error: No warnings can be incurred under -Werror.