[#222] | project: specification | priority: high | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Philippe | Martin | fixed | 2003-11-11 14:11:37.0 | |
subject | wrong type inferred for array constructor | |||
code |
object Test { def main(args:Array[String]): Unit = { val array: Array[String] = new Array(16); () } } |
|||
what happened | Exception in thread "main" java.lang.ClassCastException at Test$.main(tmp/test.scala:3) at Test.main(tmp/test.scala) |
|||
what expected | No error The problem is that the analyzer infers that the type argument of the Array constructor is All. It used to infer String. The change is probably due to the fact that arrays are now covariant. |
|||
[back to overview] |
Martin edited on 2003-11-11 14:57:29.0 |
As Philippe says this is an unwanted consequence that arrays are covariant. This goes to show that seemingly little sins have big consequences. I got frightened, and quickly changed arrays back to non-variant :-) |