From 5fa1978fac07e62570409c649faf3021b2709a18 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 7 Jun 2011 18:06:34 +0000 Subject: Modified erasure not to generate instance tests... Modified erasure not to generate instance tests for statically known types. It appears the production of types like "Foo with Bar" in the pattern matcher (where the scrutinee is known to be Foo) has been a major contributor of suboptimal pattern matches. I will also fix it in the matcher, but it makes sense to catch it in erasure as both a check on the matcher and because they may come from elsewhere too. Review by odersky. --- test/files/run/null-and-intersect.scala | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/files/run/null-and-intersect.scala (limited to 'test/files/run/null-and-intersect.scala') diff --git a/test/files/run/null-and-intersect.scala b/test/files/run/null-and-intersect.scala new file mode 100644 index 0000000000..7266dabe6d --- /dev/null +++ b/test/files/run/null-and-intersect.scala @@ -0,0 +1,34 @@ +object Test { + trait Immortal + class Bippy extends Immutable with Immortal + class Boppy extends Immutable + + def f[T](x: Traversable[T]) = x match { + case _: Map[_, _] => 3 + case _: Seq[_] => 2 + case _: Iterable[_] => 1 + case _ => 4 + } + def g(x: Bippy) = x match { + case _: Immutable with Immortal => 1 + case _ => 2 + } + def h(x: Immutable) = x match { + case _: Immortal => 1 + case _ => 2 + } + + def main(args: Array[String]): Unit = { + println(f(Set(1))) + println(f(Seq(1))) + println(f(Map(1 -> 2))) + println(f(null)) + + println(g(new Bippy)) + println(g(null)) + + println(h(new Bippy)) + println(h(new Boppy)) + println(h(null)) + } +} -- cgit v1.2.3