code |
object BugSequenceApply with Application {
val x = List(1,2,3);
case class ThreeBars extends Seq[Int] {
override def length = 3;
def elements = x.elements;
def apply(i:Int) = x.apply(i);
}
Console.println(ThreeBars().match { //pattern has type ThreeBars,
case Seq(1,2,3) => "hello" // but ThreeBars is a case class...
});
}
|
what happened |
Pattern matcher crashes, because it thinks that it needs to handle a case class with a star parameter. This is b\
ecause the pattern Seq(1,2,3) gets assigned the type ThreeBars
|