Aladdin - Scala Bugtracking
[#205] project: compiler priority: low category: missing feature
submitter assigned to status date submitted
Vincent _ fixed 2003-10-20 17:47:37.0
subject outer matching
code
class A {
  case class C();
  def f(x: Any) = x match {
    case C() => true
    case _ => false
  }
}

object matchTest {
  def main(args: Array[String]) = {
    val x = new A;
    val y = new A;
    System.out.println("" + x.f(y.C()));
  }
}
what happened
The output is "true".
what expected The output should be "false", i.e. the outer object should be taken into account when matching a case class.
[back to overview]
Changes of this bug report
Matthias  edited on  2003-10-20 23:28:50.0
The problem here is that isInstanceOf is simply mapped to a checkcast operation in the backend. Currently we don't support type tests that respect the static type system of Scala. Consequently, any tests which involve dependent types or parameterized types fail (i.e. they are not reliable).
Michel  edited on  2005-04-13 16:46:35.0
Run time types fix this bug (although they aren't enabled by default, I can compile & run the above program with RTT and it prints "false").