diff options
author | Seth Tisue <seth@tisue.net> | 2017-04-10 14:34:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-10 14:34:51 -0500 |
commit | 15e2759f49a3ef0f71290f4bbd9839cbf2346b0e (patch) | |
tree | a809f665e61208cb7e8ae098c676e80f341a68ed /test/files/neg/warn-unused-patvars.scala | |
parent | 715c88e9b74d1b4d1d0c4da9d0cc8f1b740e2dd3 (diff) | |
parent | bad61ce0ff9f460c2f8873c134a7f6bee0a53824 (diff) | |
download | scala-15e2759f49a3ef0f71290f4bbd9839cbf2346b0e.tar.gz scala-15e2759f49a3ef0f71290f4bbd9839cbf2346b0e.tar.bz2 scala-15e2759f49a3ef0f71290f4bbd9839cbf2346b0e.zip |
Merge pull request #5402 from som-snytt/issue/8040-unused
SI-8040 Improve unused warnings
Diffstat (limited to 'test/files/neg/warn-unused-patvars.scala')
-rw-r--r-- | test/files/neg/warn-unused-patvars.scala | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/files/neg/warn-unused-patvars.scala b/test/files/neg/warn-unused-patvars.scala new file mode 100644 index 0000000000..3d35dfedd6 --- /dev/null +++ b/test/files/neg/warn-unused-patvars.scala @@ -0,0 +1,53 @@ + +// verify no warning when -Ywarn-unused:-patvars + +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 + } +} |