|
[#494] |
project: nsc |
priority: low |
category: bug |
|
submitter |
assigned to |
status |
date submitted |
|
Iulian |
Martin |
fixed |
2005-11-22 13:40:42.0 |
subject |
ClassCastException inside bridge methods |
code |
object Foo extends AnyRef with Application {
val arr = Array(1, 2, 3);
def check_Ta[T](a: Array[T], f: Array[T] => Unit) = {
f(a);
}
def icheck(a: Array[Int]): Unit = { a(0) == 0; }
check_Ta(arr, icheck);
}
|
what happened |
Exception in thread "main" java.lang.ExceptionInInitializerError
at Foo.main(box2.scala)
Caused by: java.lang.ClassCastException
at Foo$$anonfun0.apply(box2.scala:214)
at Foo$.check_Ta(box2.scala:136)
at Foo$.(box2.scala:208)
at Foo$.(box2.scala)
... 1 more
|
what expected |
The bridge method for the anonymous function for icheck will cast the argument from Object to Array[Int], but it turns out the argument is in fact boxed. It should do the same test for boxed as in user-written casts. |
[back to overview] |