Reviewers: cromwellian, zundel, jbrosenberg,
Description:
When processing a this() constructor invocation, the GWT compiler
currently has a bug where it tries to reference a field that hasn't yet
been assigned.
Explanation:
1) Ordinarily, synthetic fields are assigned before user code, like
this:
public void Foo(synthArg, userArg1, userArg2) {
this.synthField = synthArg;
super();
// user code
doSomethingWith(this.synthField);
}
2) When making a this() invocation, these fields are NOT assigned yet,
because the target this() constructor is supposed to do the job:
public void Foo(synthArg, userArg1, userArg2) {
this(synthArg);
// user code
doSomethingWith(this.synthField);
}
public void Foo(synthArg) {
this.synthField = synthArg;
super();
}
3) However, sometimes the synthetic field is actually needed to even
invoke the target ctor:
public void Foo(synthArg, userArg1, userArg2) {
this(synthArg, doSomethingWith(this.synthField));
}
public void Foo(synthArg, doSomethingWithResult) {
this.synthField = synthArg;
super();
}
4) In this case, the compiler is currently broken. This change fixes it
by generating the following code instead:
public void Foo(synthArg, userArg1, userArg2) {
this(synthArg, doSomethingWith(synthArg));
}
public void Foo(synthArg, doSomethingWithResult) {
this.synthField = synthArg;
super();
}
Please review this at http://gwt-code-reviews.appspot.com/1339801/show
Affected files:
M dev/core/src/com/google/gwt/dev/jjs/impl/BuildTypeMap.java
M dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
M user/test/com/google/gwt/dev/jjs/test/InnerClassTest.java
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors