[#423] | project: compiler | priority: high | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Michel | Martin | fixed | 2005-04-24 12:48:53.0 | |
subject | Wrong handling of sequence parameters | |||
code |
object Bug { def f[T <: AnyRef](elems: T*): Unit = g(Predef.Array(elems : _*)); def g[T <: AnyRef](x: Array[T]): Unit = (); def main(args: Array[String]): Unit = { f("a","b") } } |
|||
what happened | Exception in thread "main" java.lang.ClassCastException at Bug$.f(bug-uncurry.scala:3) at Bug$.main(bug-uncurry.scala:8) at Bug.main(bug-uncurry.scala:7) |
|||
what expected | A working program. The problem turns out to be due to a strange transformation performed by UnCurry. Before it, the "f" function looks like:
final def f[T <: java.lang.Object](elems: scala.Seq[T]): scala.Unit = Bug.this.g[T](scala.Predef.Array[T]((elems) : _*));and after it: final def f[T <: java.lang.Object](elems: scala.Seq[T]): scala.Unit = Bug.this.g[T]({ scala.Predef; elems });which is wrong, as elems is, I believe, a List and not an Array. |
|||
[back to overview] |
Burak edited on 2005-05-25 18:31:39.0 |
The transformation is indeed strange, and maybe it should be in a phase of its own. Usually, If the Sequence |
Burak edited on 2005-05-25 18:32:40.0 |
So the result after UnCurry looks like this, as it should.
final def f[final T <: java.lang.Object](final elems: scala.Seq[T]): scala.Unit = Bug.this.g[T](scala.Predef.Array[T](elems)); |