diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-01-27 19:01:25 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-01-29 11:09:17 +1000 |
commit | 79a52e6807d2797dee12bab1730765441a0e222d (patch) | |
tree | 7dadef54293eee75a2cf93572a0365bd1bea0dc9 /test/files/pos/t9411b.scala | |
parent | bbd890bf907c00f17df39eb4bc656b30d4317b9a (diff) | |
download | scala-79a52e6807d2797dee12bab1730765441a0e222d.tar.gz scala-79a52e6807d2797dee12bab1730765441a0e222d.tar.bz2 scala-79a52e6807d2797dee12bab1730765441a0e222d.zip |
SI-9630 Fix spurious warning related to same-named case accessors
Hash consing of trees within pattern match analysis was broken, and
considered `x1.foo#1` to be the same tree as `x1.foo#2`, even though
the two `foo`-s referred to different symbols.
The hash consing was based on `Tree#correspondsStructure`, but the
predicate in that function cannot veto correspondance, it can only
supplement the default structural comparison.
I've instead created a custom tree comparison method for use in
the pattern matcher that handles the tree shapes that we use.
Diffstat (limited to 'test/files/pos/t9411b.scala')
-rw-r--r-- | test/files/pos/t9411b.scala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/files/pos/t9411b.scala b/test/files/pos/t9411b.scala new file mode 100644 index 0000000000..6888ba9382 --- /dev/null +++ b/test/files/pos/t9411b.scala @@ -0,0 +1,36 @@ +object OhNoes { + + sealed trait F + sealed abstract class FA extends F + sealed abstract class FB extends F + + case object FA1 extends FA + case object FB1 extends FB + case object FB2 extends FB + + sealed trait G + case object G1 extends G + case object G2 extends G + + sealed trait H + case class H1(a: FB, b: G) extends H + case class H2(b: F) extends H + + val demo: H => Unit = { + case H1(FB1, G1) => + case H1(FB2, G2) => + case H2(_: FB) => + case H2(_: FA) => + case H1(FB1, G2) => + case H1(FB2, G1) => + } + + val demo2: H => Unit = { + case H2(_: FA) => + case H2(_: FB) => + case H1(FB1, G1) => + case H1(FB2, G1) => + case H1(FB1, G2) => + case H1(FB2, G2) => + } +} |