Martin edited on 2007-05-11 00:41:13.0
|
It seems the backend is changing the reference
A.this.v = "foo"
to
A$.MODULE$.v = "foo"
Because A$.MODULE is assigned only after the superclass constructor is called we get an NullPointerException.
You can verify by printing the constructor of A at phase cleanup (then it looks still OK) and doing a javap afterwards.
Question: Why the replacement? Would it not be more efficient in general to keep `this' references?
|
Iulian edited on 2007-05-11 16:43:45.0
|
Fixed. The problem was treating object values too uniformly. Actually the tree is not A.this.v = ... but simply A.v, where A carries the module symbol. The code generator blindly generated the same code for all module references, by reading the MODULE$ field. Now it checks first to see if the module we're accessing is the same as the class we're generating, in which case it replaces it by 'this'.
|