Fix for Issue #4002
Patch by: cromwellian
Review by: scottb


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6405 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
index 3b74a87..bf5aaf6 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
@@ -1948,7 +1948,12 @@
         JExpression expr, JClassType classType) {
       if (classType.getFields().size() > 0) {
         JField field = classType.getFields().get(0);
-        if (field.getName().startsWith("this$")) {
+        /* In some circumstances, the outer this ref can be captured as a local
+         * value (val$this), in other cases, as a this ref (this$).
+         * TODO: investigate using more JDT node information as an alternative
+         */
+        if (field.getName().startsWith("this$") ||
+            field.getName().startsWith("val$this$")) {
           list.add(new JFieldRef(expr.getSourceInfo(), expr, field,
               currentClass));
         }