diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/warn-unused-imports/warn-unused-imports_2.scala | 2 | ||||
-rw-r--r-- | test/files/neg/warn-unused-patvars.check | 12 | ||||
-rw-r--r-- | test/files/neg/warn-unused-patvars.flags | 1 | ||||
-rw-r--r-- | test/files/neg/warn-unused-patvars.scala | 51 |
4 files changed, 65 insertions, 1 deletions
diff --git a/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala b/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala index ded1186209..56ad3393a1 100644 --- a/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala +++ b/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala @@ -96,7 +96,7 @@ trait Warn { trait Nested { { import p1._ // warn - trait Warn { // warn about unused local trait for good measure + trait Warn { // don't warn about unused local trait with -Ywarn-unused:imports import p2._ println(new A) println("abc".bippy) diff --git a/test/files/neg/warn-unused-patvars.check b/test/files/neg/warn-unused-patvars.check new file mode 100644 index 0000000000..002f7a07ca --- /dev/null +++ b/test/files/neg/warn-unused-patvars.check @@ -0,0 +1,12 @@ +warn-unused-patvars.scala:7: warning: private val x in trait Boundings is never used + private val x = 42 // warn, sanity check + ^ +warn-unused-patvars.scala:26: warning: local val x in method v is never used + val D(x) = d // warn, fixme + ^ +warn-unused-patvars.scala:30: warning: local val x in method w is never used + val D(x @ _) = d // warn, fixme (valdef pos is different) + ^ +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/warn-unused-patvars.flags b/test/files/neg/warn-unused-patvars.flags new file mode 100644 index 0000000000..d5bd86a658 --- /dev/null +++ b/test/files/neg/warn-unused-patvars.flags @@ -0,0 +1 @@ +-Ywarn-unused:-patvars,_ -Xfatal-warnings diff --git a/test/files/neg/warn-unused-patvars.scala b/test/files/neg/warn-unused-patvars.scala new file mode 100644 index 0000000000..6f4620c0c7 --- /dev/null +++ b/test/files/neg/warn-unused-patvars.scala @@ -0,0 +1,51 @@ + +case class C(a: Int, b: String, c: Option[String]) +case class D(a: Int) + +trait Boundings { + + private val x = 42 // warn, sanity check + + def c = C(42, "hello", Some("world")) + def d = D(42) + + def f() = { + val C(x, y, Some(z)) = c // no warn + 17 + } + def g() = { + val C(x @ _, y @ _, Some(z @ _)) = c // no warn + 17 + } + def h() = { + val C(x @ _, y @ _, z @ Some(_)) = c // no warn for z? + 17 + } + + def v() = { + val D(x) = d // warn, fixme + 17 + } + def w() = { + val D(x @ _) = d // warn, fixme (valdef pos is different) + 17 + } + +} + +trait Forever { + def f = { + val t = Option((17, 42)) + for { + ns <- t + (i, j) = ns // no warn + } yield (i + j) + } + def g = { + val t = Option((17, 42)) + for { + ns <- t + (i, j) = ns // no warn + } yield 42 + } +} |