diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-04-29 14:38:35 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-05-07 15:45:19 +0200 |
commit | 1ba2d7bb967ded0c19ff2cf966c492adc12292bb (patch) | |
tree | 1bb3f342d8a2060b461020c9e3431bbd3eff2a58 /test/files/pos | |
parent | ca9003e453873c496c72c431f0e5f9f3eaf31511 (diff) | |
download | scala-1ba2d7bb967ded0c19ff2cf966c492adc12292bb.tar.gz scala-1ba2d7bb967ded0c19ff2cf966c492adc12292bb.tar.bz2 scala-1ba2d7bb967ded0c19ff2cf966c492adc12292bb.zip |
SI-8546 Pattern matcher analysis foiled by over-widening
In the enclosed test, the prefix checkable type
`ModuleTypeRef(F2.this, C)` was being inadvertently widened to
`ModuleTypeRef(F2[?], C)`. This started after some misguided
future-proofing in SI-6771 / 3009916.
This commit changes the `dealiasWiden` to a `delias`.
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/t8546.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t8546.scala | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/test/files/pos/t8546.flags b/test/files/pos/t8546.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t8546.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t8546.scala b/test/files/pos/t8546.scala new file mode 100644 index 0000000000..c39d749b4c --- /dev/null +++ b/test/files/pos/t8546.scala @@ -0,0 +1,49 @@ +package test + +class F1() { + private sealed abstract class T + private case class A(m: Int) extends T + private case class B() extends T + private case object C extends T + + // No warnings here + private def foo(t: T) = t match { + case A(m) => println("A:" + m) + case B() => println("B") + case C => println("C") + } + + def test(m: Int): Unit = { + foo(A(m)) + foo(B()) + foo(C) + } +} + +class F2[M]() { + private sealed abstract class T + private case class A(m: M) extends T + private case class B() extends T + private case object C extends T + + // match may not be exhaustive. It would fail on the following input: C + private def foo(t: T) = t match { + case A(m) => println("A:" + m) + case B() => println("B") + case C => println("C") + } + + def test(m: M): Unit = { + foo(A(m)) + foo(B()) + foo(C) + } + +} + +object Test { + def main(args: Array[String]): Unit = { + new F1().test(1) + new F2[Int]().test(1) + } +}
\ No newline at end of file |