[#480] | project: compiler | priority: low | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Iulian | _ | fixed | 2005-11-09 12:30:56.0 | |
subject | missing unbox operation | |||
code |
object Foo extends AnyRef with Application { def id_ST[S <: Any, T <: Array[S]](x: T): Any = x; val a: Array[Int] = Array(1, 2, 3); Console.println("" + a + " = " + id_ST[Int, Array[Int]](a).asInstanceOf[Array[Int]]); } |
|||
what happened | Exception in thread "main" java.lang.ExceptionInInitializerError at Foo.main(box.scala) Caused by: java.lang.ClassCastException at Foo$.The identity method returns the boxed array, but the caller forgets to unbox it. |
|||
what expected | Unboxing the result of id_ST. More examples of the desired behavior can be found in test-nsc/files/run/arrays.scala | |||
[back to overview] |
Iulian edited on 2005-11-10 10:46:06.0 |
I reopened the bug because it reappears when the identity method is given the explicit return type 'Any'. A very useful test for these cases seems to be test-nsc/files/run/arrays.scala. |
Iulian edited on 2005-11-10 10:46:16.0 |
Martin edited on 2006-03-28 11:00:27.0 |