Aladdin - Scala Bugtracking
[#748] project: compiler priority: low category: bug
submitter assigned to status date submitted
Iulian Martin fixed 2006-09-21 09:29:40.0
subject Erasure missing array box operation for selection
code
object ExSimple {
  def id[a](x: a): a = x;
  def main(args: Array[String]): Unit = {
    val x = Pair(Predef.Array(4, 5, 6), "mittu")

    // the following two lines fail at runtime
    //x._1 foreach Console.println
    id(Predef.Array(1, 2, 3)) foreach Console.println
  }
}
what happened
java.lang.ClassCastException: [I
        at ExSimple$.main(buglukas.scala:6)
        at ExSimple.main(buglukas.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:53)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:96)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
what expected No crash. If we store the array to a local first, boxing occurs correctly and the program runs fine.fixed bug748; improved display of `new' in TreePrinters
[back to overview]
Changes of this bug report
Martin  edited on  2006-09-21 13:07:22.0