-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
162 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
-- [E176] Potential Issue Warning: tests/warn/i18559.scala:63:4 -------------------------------------------------------- | ||
63 | improved // warn | ||
| ^^^^^^^^ | ||
| unused value of type (improved : => scala.concurrent.Future[Int]) | ||
-- [E175] Potential Issue Warning: tests/warn/i18559.scala:51:35 ------------------------------------------------------- | ||
51 | firstThing().map(_ => secondThing()) // warn | ||
| ^^^^^^^^^^^^^ | ||
| discarded non-Unit value of type Either[Failed, Unit] | ||
-- [E175] Potential Issue Warning: tests/warn/i18559.scala:54:35 ------------------------------------------------------- | ||
54 | firstThing().map(_ => secondThing()) // warn | ||
| ^^^^^^^^^^^^^ | ||
| discarded non-Unit value of type Either[Failed, Unit] | ||
-- Warning: tests/warn/i18559.scala:4:6 -------------------------------------------------------------------------------- | ||
4 | var e3 = 2 // warn | ||
| ^^ | ||
| unused local definition | ||
-- Warning: tests/warn/i18559.scala:8:28 ------------------------------------------------------------------------------- | ||
8 | import collection.mutable.Set // warn | ||
| ^^^ | ||
| unused import | ||
-- Warning: tests/warn/i18559.scala:9:33 ------------------------------------------------------------------------------- | ||
9 | import collection.mutable.{Map => MutMap} // warn | ||
| ^^^^^^^^^^^^^ | ||
| unused import | ||
-- Warning: tests/warn/i18559.scala:10:28 ------------------------------------------------------------------------------ | ||
10 | import collection.mutable._ // warn | ||
| ^ | ||
| unused import | ||
-- Warning: tests/warn/i18559.scala:13:28 ------------------------------------------------------------------------------ | ||
13 | import collection.mutable._ // warn | ||
| ^ | ||
| unused import | ||
-- [E030] Match case Unreachable Warning: tests/warn/i18559.scala:31:10 ------------------------------------------------ | ||
31 | case Sum(a@S(_),Z) => Z // warn | ||
| ^^^^^^^^^^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/i18559.scala:32:10 ------------------------------------------------ | ||
32 | case Sum(a@S(_),Z) => a // warn unreachable | ||
| ^^^^^^^^^^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/i18559.scala:33:10 ------------------------------------------------ | ||
33 | case Sum(a@S(b@S(_)), Z) => a // warn | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/i18559.scala:34:10 ------------------------------------------------ | ||
34 | case Sum(a@S(b@S(_)), Z) => a // warn | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/i18559.scala:35:10 ------------------------------------------------ | ||
35 | case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // warn unreachable | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| Unreachable case | ||
-- [E121] Pattern Match Warning: tests/warn/i18559.scala:37:7 ---------------------------------------------------------- | ||
37 | case _ => Z // warn unreachable | ||
| ^ | ||
| Unreachable case except for null (if this is intentional, consider writing case null => instead). |
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,66 @@ | ||
//> using options -W:default | ||
|
||
val b = // OK | ||
var e3 = 2 // warn | ||
1 | ||
|
||
object FooUnused: | ||
import collection.mutable.Set // warn | ||
import collection.mutable.{Map => MutMap} // warn | ||
import collection.mutable._ // warn | ||
|
||
object FooWildcardUnused: | ||
import collection.mutable._ // warn | ||
|
||
object Foo: | ||
import collection.mutable.Set // OK | ||
import collection.mutable.{Map => MutMap} // OK | ||
|
||
val bar = Set() // OK | ||
val baz = MutMap() // OK | ||
|
||
sealed trait Calc | ||
sealed trait Const extends Calc | ||
case class Sum(a: Calc, b: Calc) extends Calc | ||
case class S(pred: Const) extends Const | ||
case object Z extends Const | ||
|
||
val a = Sum(S(S(Z)),Z) match { | ||
case Sum(a,Z) => Z // not warn: patvars not enabled by Wall | ||
// case Sum(a @ _,Z) => Z // todo : this should pass in the future | ||
case Sum(a@S(_),Z) => Z // warn | ||
case Sum(a@S(_),Z) => a // warn unreachable | ||
case Sum(a@S(b@S(_)), Z) => a // warn | ||
case Sum(a@S(b@S(_)), Z) => a // warn | ||
case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // warn unreachable | ||
case Sum(_,_) => Z // OK | ||
case _ => Z // warn unreachable | ||
} | ||
import scala.util.{Either, Right, Left} | ||
import scala.collection.mutable | ||
|
||
case class Failed(msg: String) | ||
|
||
def firstThing(): Either[Failed, Unit] = | ||
Right(()) | ||
|
||
def secondThing(): Either[Failed, Unit] = | ||
Left(Failed("whoops you should have flatMapped me")) | ||
|
||
def singleExpr(): Either[Failed, Unit] = | ||
firstThing().map(_ => secondThing()) // warn | ||
|
||
def block(): Either[Failed, Unit] = { | ||
firstThing().map(_ => secondThing()) // warn | ||
} | ||
|
||
class C { | ||
import concurrent._ | ||
import ExecutionContext.Implicits._ | ||
def c = { | ||
def improved = Future(42) | ||
def stale = Future(27) | ||
improved // warn | ||
stale | ||
} | ||
} |