Fixes ICE in JsInliner.

We are getting a compiler crash if you try to inline a static JSNI method that references 'this' (weird case).  This change disables inlining such methods.

http://gwt-code-reviews.appspot.com/284802/show
Found by: spoon
Review by: spoon


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7914 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/js/JsInliner.java b/dev/core/src/com/google/gwt/dev/js/JsInliner.java
index 1cef6f4..00d1b7a 100644
--- a/dev/core/src/com/google/gwt/dev/js/JsInliner.java
+++ b/dev/core/src/com/google/gwt/dev/js/JsInliner.java
@@ -1368,25 +1368,36 @@
 
   /**
    * Detects uses of parameters that would produce incorrect results if inlined.
-   * Generally speaking, we disallow the use of parameters as lvalues.
+   * Generally speaking, we disallow the use of parameters as lvalues. Also
+   * detects trying to inline a method which references 'this' where the call
+   * site has no qualifier.
    */
   private static class ParameterUsageVisitor extends JsVisitor {
-    private boolean lvalue = false;
+    private final boolean hasThisExpr;
     private final Set<JsName> parameterNames;
+    private boolean violation = false;
 
-    public ParameterUsageVisitor(Set<JsName> parameterNames) {
+    public ParameterUsageVisitor(boolean hasThisExpr, Set<JsName> parameterNames) {
+      this.hasThisExpr = hasThisExpr;
       this.parameterNames = parameterNames;
     }
 
     @Override
     public void endVisit(JsNameRef x, JsContext<JsExpression> ctx) {
       if (ctx.isLvalue() && isParameter(x)) {
-        lvalue = true;
+        violation = true;
       }
     }
 
-    public boolean parameterAsLValue() {
-      return lvalue;
+    @Override
+    public void endVisit(JsThisRef x, JsContext<JsExpression> ctx) {
+      if (!hasThisExpr) {
+        violation = true;
+      }
+    }
+
+    public boolean hasViolation() {
+      return violation;
     }
 
     /**
@@ -1911,9 +1922,10 @@
     }
 
     // Check that parameters aren't used in such a way as to prohibit inlining
-    ParameterUsageVisitor v = new ParameterUsageVisitor(parameterNames);
+    ParameterUsageVisitor v = new ParameterUsageVisitor(thisExpr != null,
+        parameterNames);
     v.accept(toInline);
-    if (v.parameterAsLValue()) {
+    if (v.hasViolation()) {
       return false;
     }