From 5c43c66f9986720c59445c0c42707bd24c12557b Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 20 Oct 2023 10:55:31 +0200 Subject: [PATCH] Cleanup pure statement warning The `you may be omitting necessary parentheses` hint in the message was added when we used to get method references that became lambdas in statement positions. Now these are an error and never reach this warning. --- compiler/src/dotty/tools/dotc/reporting/messages.scala | 2 +- compiler/test-resources/repl/nowarn.scala | 2 +- tests/neg-macros/annot-suspend-cycle.check | 2 +- tests/neg/i18408a.check | 2 +- tests/neg/i18408b.check | 2 +- tests/neg/i18408c.check | 2 +- tests/neg/nowarn.check | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index 78fd464cc9f0..931e19b6031e 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -2403,7 +2403,7 @@ class MemberWithSameNameAsStatic()(using Context) class PureExpressionInStatementPosition(stat: untpd.Tree, val exprOwner: Symbol)(using Context) extends Message(PureExpressionInStatementPositionID) { def kind = MessageKind.PotentialIssue - def msg(using Context) = "A pure expression does nothing in statement position; you may be omitting necessary parentheses" + def msg(using Context) = "A pure expression does nothing in statement position" def explain(using Context) = i"""The pure expression $stat doesn't have any side effect and its result is not assigned elsewhere. |It can be removed without changing the semantics of the program. This may indicate an error.""" diff --git a/compiler/test-resources/repl/nowarn.scala b/compiler/test-resources/repl/nowarn.scala index 5038cda7094e..975f9c72a809 100644 --- a/compiler/test-resources/repl/nowarn.scala +++ b/compiler/test-resources/repl/nowarn.scala @@ -27,7 +27,7 @@ scala> def f = { 1; 2 } -- [E129] Potential Issue Warning: --------------------------------------------- 1 | def f = { 1; 2 } | ^ - |A pure expression does nothing in statement position; you may be omitting necessary parentheses + | A pure expression does nothing in statement position | | longer explanation available when compiling with `-explain` def f: Int diff --git a/tests/neg-macros/annot-suspend-cycle.check b/tests/neg-macros/annot-suspend-cycle.check index 237cbe4188b2..e3ecea7345fd 100644 --- a/tests/neg-macros/annot-suspend-cycle.check +++ b/tests/neg-macros/annot-suspend-cycle.check @@ -1,7 +1,7 @@ -- [E129] Potential Issue Warning: tests/neg-macros/annot-suspend-cycle/Macro.scala:7:4 -------------------------------- 7 | new Foo | ^^^^^^^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | A pure expression does nothing in statement position | | longer explanation available when compiling with `-explain` Cyclic macro dependencies in tests/neg-macros/annot-suspend-cycle/Test.scala. diff --git a/tests/neg/i18408a.check b/tests/neg/i18408a.check index fbd67ef3052a..ff278e6fe5cb 100644 --- a/tests/neg/i18408a.check +++ b/tests/neg/i18408a.check @@ -13,6 +13,6 @@ -- [E129] Potential Issue Warning: tests/neg/i18408a.scala:4:16 -------------------------------------------------------- 4 |def test2 = fa({42; ()}) | ^^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | A pure expression does nothing in statement position | | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i18408b.check b/tests/neg/i18408b.check index 2bfc8c24f1dd..7c72833fe5ad 100644 --- a/tests/neg/i18408b.check +++ b/tests/neg/i18408b.check @@ -13,6 +13,6 @@ -- [E129] Potential Issue Warning: tests/neg/i18408b.scala:4:16 -------------------------------------------------------- 4 |def test2 = fa({42; ()}) | ^^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | A pure expression does nothing in statement position | | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i18408c.check b/tests/neg/i18408c.check index 2e8a279764d6..078f42bb0006 100644 --- a/tests/neg/i18408c.check +++ b/tests/neg/i18408c.check @@ -13,6 +13,6 @@ -- [E129] Potential Issue Warning: tests/neg/i18408c.scala:4:16 -------------------------------------------------------- 4 |def test2 = fa({42; ()}) | ^^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | A pure expression does nothing in statement position | | longer explanation available when compiling with `-explain` diff --git a/tests/neg/nowarn.check b/tests/neg/nowarn.check index a8075335290a..636cabd44d07 100644 --- a/tests/neg/nowarn.check +++ b/tests/neg/nowarn.check @@ -32,7 +32,7 @@ Matching filters for @nowarn or -Wconf: -- [E129] Potential Issue Warning: tests/neg/nowarn.scala:15:11 -------------------------------------------------------- 15 |def t2 = { 1; 2 } // warning (the invalid nowarn doesn't silence anything) | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | A pure expression does nothing in statement position | | longer explanation available when compiling with `-explain` -- Warning: tests/neg/nowarn.scala:14:8 -------------------------------------------------------------------------------- @@ -43,7 +43,7 @@ Matching filters for @nowarn or -Wconf: -- [E129] Potential Issue Warning: tests/neg/nowarn.scala:18:12 -------------------------------------------------------- 18 |def t2a = { 1; 2 } // warning (invalid nowarn doesn't silence) | ^ - | A pure expression does nothing in statement position; you may be omitting necessary parentheses + | A pure expression does nothing in statement position | | longer explanation available when compiling with `-explain` -- Warning: tests/neg/nowarn.scala:17:8 --------------------------------------------------------------------------------