From a03131199109b51b4a3051aa2c016d516bec6e36 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 3 Oct 2010 22:53:59 +0000 Subject: Work on the pattern matcher. patches for #3887 and #3888, but I determined that I could achieve the same effect by deleting a bunch of code, so I did. This left only a few lines in TransMatch, so I eliminated it, which led me to remember that many places still reference non-existent phase transmatch, so those were updated. Notes: * This swaps equality tests on stable identifier patterns. They have never conformed to the spec (as noted long ago in ticket #785) which says "The pattern matches any value v such that r == v" whereas until now the test being performed was v == r. * An issue was introduced with specialization in that the implementation of "isTupleType" in Definitions relied upon sym == TupleClass(elems.length). This test is untrue for specialized tuples, causing mysterious behavior because only some tuples are specialized. There is now "isTupleTypeOrSubtype" although it seems likely the former implementation is unnecessary. The issue is sidestepped if one uses "getProductArgs" to retrieve the element types because it sifts through the base types for the Product symbol. Closes #3887 and #3888, review by dmharrah. --- test/files/run/t3888.scala | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/files/run/t3888.scala (limited to 'test/files/run/t3888.scala') diff --git a/test/files/run/t3888.scala b/test/files/run/t3888.scala new file mode 100644 index 0000000000..ecdf87e925 --- /dev/null +++ b/test/files/run/t3888.scala @@ -0,0 +1,26 @@ +object Test { + + val T1 = new P + private[this] val T2 = T1 + + def m1 = + (1, 2) match { + case T1 => true + case _ => false + } + + def m2 = + (1, 2) match { + case T2 => true + case _ => false + } + + def main(args: Array[String]) = { + assert( m1 ) + assert( m2 ) + } +} + +class P extends Pair(1, 1) { + override def equals(x: Any) = true +} \ No newline at end of file -- cgit v1.2.3