forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#10641 from som-snytt/tweak/remove-ad-for-mit…
…igation Either lint unused or warn discarded or warn pure
- Loading branch information
Showing
32 changed files
with
237 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
toughtype.scala:175: warning: multiline expressions might require enclosing parentheses; a value can be silently discarded when Unit is expected | ||
identity[A] _ | ||
^ | ||
toughtype.scala:175: warning: a pure expression does nothing in statement position | ||
toughtype.scala:175: warning: discarded pure expression does nothing | ||
identity[A] _ | ||
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
discard-advice-a.scala:7: warning: unused value of type scala.concurrent.Future[Int] | ||
Future(42) | ||
^ | ||
discard-advice-a.scala:10: warning: unused value of type scala.concurrent.Future[Int] | ||
Future(42) | ||
^ | ||
discard-advice-a.scala:11: warning: unused value of type Boolean(true) | ||
true | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
3 warnings | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//> using options -Werror -Wnonunit-statement -Wvalue-discard | ||
|
||
import concurrent._, ExecutionContext.Implicits._ | ||
|
||
class C { | ||
def f(): Unit = { | ||
Future(42) | ||
} | ||
def g(): Unit = { | ||
Future(42) | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
discard-advice-b.scala:7: warning: discarded non-Unit value of type scala.concurrent.Future[Int] | ||
Future(42) | ||
^ | ||
discard-advice-b.scala:11: warning: discarded non-Unit value of type Boolean(true) | ||
true | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
2 warnings | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//> using options -Werror -Wvalue-discard | ||
|
||
import concurrent._, ExecutionContext.Implicits._ | ||
|
||
class C { | ||
def f(): Unit = { | ||
Future(42) | ||
} | ||
def g(): Unit = { | ||
Future(42) | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
discard-advice-c.scala:11: warning: discarded pure expression does nothing | ||
true | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
1 warning | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//> using options -Werror | ||
|
||
import concurrent._, ExecutionContext.Implicits._ | ||
|
||
class C { | ||
def f(): Unit = { | ||
Future(42) | ||
} | ||
def g(): Unit = { | ||
Future(42) | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
discard-advice-d.scala:7: warning: unused value of type scala.concurrent.Future[Int] | ||
Applicable -Wconf / @nowarn filters for this warning: msg=<part of the message>, cat=other-pure-statement, site=C.f | ||
Future(42) | ||
^ | ||
discard-advice-d.scala:10: warning: unused value of type scala.concurrent.Future[Int] | ||
Applicable -Wconf / @nowarn filters for this warning: msg=<part of the message>, cat=other-pure-statement, site=C.g | ||
Future(42) | ||
^ | ||
discard-advice-d.scala:11: warning: unused value of type Boolean(true) | ||
Applicable -Wconf / @nowarn filters for this warning: msg=<part of the message>, cat=other-pure-statement, site=C.g | ||
true | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
3 warnings | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//> using options -Wconf:any:warning-verbose -Werror -Wnonunit-statement -Wvalue-discard | ||
|
||
import concurrent._, ExecutionContext.Implicits._ | ||
|
||
class C { | ||
def f(): Unit = { | ||
Future(42) | ||
} | ||
def g(): Unit = { | ||
Future(42) | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,51 @@ | ||
nonunit-if.scala:58: warning: discarded non-Unit value of type U | ||
if (!isEmpty) f(a) // warn, check is on | ||
^ | ||
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. | ||
18 warnings | ||
16 warnings | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
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 | ||
^ | ||
nonunit-statement.scala:202: warning: a pure expression does nothing in statement position | ||
null // warn for purity, but <init> does not cause multiline clause | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
12 warnings | ||
13 warnings | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.