| [#351] | project: compiler | priority: high | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Burak | Philippe | fixed | 2004-07-16 19:13:35.0 | |
| subject | VerifyError on Array[A] where A abstract type member | |||
| code |
abstract class Foo {
type A = bar.A;
val bar:Bar;
bar.handleBaz( new Array[A](0) );
}
abstract class Bar {
type A;
def handleBaz(arr:Array[A]) = 0;
}
object Test with Application {
new Foo {
val bar = new Bar {
type A = Int; // using some AnyRef also yields error
}
}
}
|
|||
| what happened | /tmp> /local/buraq/scala.fallback/scala/bin/scala Test Exception in thread "main" java.lang.ExceptionInInitializerError at Test.main(foo.scala:45) Caused by: java.lang.NullPointerException at Foo$class.This is the bytecode: |
|||
| what expected | hm, erase Array[A] to Array[Object] in call to Bar::handleBaz ?
|
|||
| [back to overview] | ||||
| Burak edited on 2004-07-16 19:14:20.0 |
| In absence of Michel, I assign this one to Philippe, maybe you can help, I am depending on this to work... |
| Philippe edited on 2004-07-19 11:08:20.0 |
I don't see any VerifyError. There is only a NullPointerException because bar is access from Foo before it is initialized in the anonymous subclass. If you add to class bar then everything is ok.
|
| Burak edited on 2004-07-19 12:03:46.0 |
| I can reproduce this error, with the latest CVS as well as with the /home/linuxsoft version. |
| Philippe edited on 2004-07-19 13:39:38.0 |
Indeed, the error can be reproduced, but as I explained that's the correct behaviour. The problem is that you access a non-initialized value in class Foo. Here is a shorter example which exhibits the same error.
abstract class Foo {
val v: Any;
System.out.println(v.toString());
}
object Test with Application {
new Foo {
val v: Any = "initial-value-that-comes-to-late";
}
}
When System.out.println(v.toString()); is executed, v is not yet initialized.
|