Aladdin - Scala Bugtracking
[#462] project: nsc priority: medium category: bug
submitter assigned to status date submitted
Iulian _ fixed 2005-10-18 11:26:12.0
subject [nsc] Erasure introduces erronous casts
code
class Foo {
  def test(n: Int) = 4.asInstanceOf[Char];
}
what happened
[[syntax trees at end of erasure]]// Scala source: box.scala
package  {
  class Foo extends java.lang.Object with scala.ScalaObject$class {
    def (): Foo = {
      super.();
      Foo.super[ScalaObject$class].$init$();
      ()
    };
    def test(): scala.Char = scala.runtime.BoxedInt.box(4).$asInstanceOf[scala.Char]()
  }
}
what expected The box is unnecessary, the cast should be treated in the backend as a value conversion from int to char. The boxing introduces a ClassCastException at runtime, because BoxedInt is not an (Boxed)Char.
[back to overview]
Changes of this bug report
Iulian  edited on  2005-10-18 13:35:04.0
Iulian  edited on  2005-10-18 14:14:47.0
Iulian  edited on  2005-11-04 10:37:23.0