Fix inconsistency in MethodInliner.

MethodInliner would create an instance of JNonNullType whose
underlying type was JNullType. Leaving the AST in an illegal
state where further passes down the road could be making wrong
decisions.

Change-Id: I2bbca4692b6eadb609a22b1016a834fd94bc7840
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JNullType.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JNullType.java
index 0bd8bff..c5ecc15 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JNullType.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JNullType.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -62,4 +62,9 @@
   private Object readResolve() {
     return INSTANCE;
   }
+
+  @Override
+  public JNonNullType getNonNull() {
+    throw new UnsupportedOperationException();
+  }
 }
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java b/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
index f991aaf..ae2ce51 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2007 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -50,7 +50,7 @@
  * Inline methods that can be inlined. The current implementation limits the
  * methods that can be inlined to those that are composed of at most two
  * top-level expressions.
- * 
+ *
  * Future improvements will allow more complex methods to be inlined based on
  * the number of call sites, as well as adding support for more complex target
  * method expressions.
@@ -154,7 +154,7 @@
          * tighten an instance call to its static impl after the static impl had
          * already been inlined, this meant any "flow" type optimizer would have
          * to fake artifical flow from the instance method to the static impl.
-         * 
+         *
          * TODO: allow the inlining if we are the last remaining call site, and
          * prune the static impl? But it might tend to generate more code.
          */
@@ -213,7 +213,7 @@
      * Creates a JMultiExpression from a set of JExpressionStatements,
      * optionally terminated by a JReturnStatement. If the method doesn't match
      * this pattern, it returns <code>null</code>.
-     * 
+     *
      * If a method has a non-void return statement and can be represented as a
      * multi-expression, the output of the multi-expression will be the return
      * expression of the method. If the method is void, the output of the
@@ -289,7 +289,7 @@
        * Limit inlined methods to multiexpressions of length 2 for now. This
        * handles the simple { return JVariableRef; } or { expression; return
        * something; } cases.
-       * 
+       *
        * TODO: add an expression complexity analyzer.
        */
       if (targetExpr.getNumberOfExpressions() > 2) {
@@ -320,7 +320,7 @@
       /*
        * There are a different number of parameters than args - this is likely a
        * result of parameter pruning. Don't consider this call site a candidate.
-       * 
+       *
        * TODO: would this be possible in the trivial delegation case?
        */
       if (x.getTarget().getParams().size() != x.getArgs().size()) {
@@ -391,7 +391,7 @@
    * Verifies that all the parameters are referenced once and only once, not
    * within a conditionally-executing expression, and any before trouble some
    * expressions evaluate. Examples of troublesome expressions include:
-   * 
+   *
    * <ul>
    * <li>assignments to any variable</li>
    * <li>expressions that throw exceptions</li>
@@ -556,7 +556,11 @@
     } else {
       result = target;
     }
-    if ((!target.canBeNull())) {
+
+    // TODO(rluble): Replace a (non nullable) type by its JNonNullType version is always safe; but
+    // there already exists a pass that is responsible for making types tighten (TypeTightener)
+    // hence leaving this tightening unnecessary as it will be performed by a different pass.
+    if (!result.canBeNull()) {
       result = result.getNonNull();
     }
     return result;