Aladdin - Scala Bugtracking
[#1243] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Gilles Martin fixed 2007-07-25 18:30:36.0
subject Extending and requiring classes that define homonymous case classes crashes fjbg
code
trait A {  }
trait X { case class Error }
trait B extends X { a: A =>
  Error match { case Error() => }
}
what happened
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
        at ch.epfl.lamp.fjbg.JExtendedCode.emitT2T(JExtendedCode.java:426)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genPrimitive(GenJVM.scala:1153)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$44.apply(GenJVM.scala:753)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$44.apply(GenJVM.scala:658)
        at scala.Iterator$class.foreach(Iterator.scala:375)
        at scala.runtime.BoxedArray$$anon$0.foreach(BoxedArray.scala:46)
        at scala.Iterable$class.foreach(Iterable.scala:241)
        at scala.runtime.BoxedArray.foreach(BoxedArray.scala:25)
        at scala.tools.nsc.backend.icode.BasicBlocks$BasicBlock.traverse(BasicBlocks.scala:102)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genBlock(GenJVM.scala:658)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genBlocks(GenJVM.scala:579)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genCode(GenJVM.scala:568)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genMethod(GenJVM.scala:453)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$5.apply(GenJVM.scala:195)
        at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$5.apply(GenJVM.scala:195)
        ...
what expected The compiler not crashing.
[back to overview]
Changes of this bug report
Iulian  edited on  2007-08-06 17:06:40.0
It has nothing to do with the fact that both A and X define a case class Error. It crashes the same with an empty 'A'. I updated the example and the icode generator to crash on invalid code. The invalid tree is: def /*B$class*/$init$($this: A): Unit = { val temp6: X$Error = new X$Error($this); .. } and X$Error constructor: def this($outer: X): X$Error = { So we pass an 'A' instead of an 'X', erasure should insert a cast.
Martin  edited on  2007-08-22 15:13:30.0