Fix AutoBeanFactoryGenerator in preparation for Java8 Collections update

Three bugs are fixed here, to support new Java8 methods which will be
added soon to GWT. These are written to be general enough to support
these same techniques in user-created autobeans.

First, don't attempt to shim static methods - they aren't needed, and
they confuse the compiler.

Second, when ModelUtils is asked for a base type, it should know that
isWildcard can return type parameters, so unwrap again.

Third, since generated autobean instances already throw away generics,
cast all return values to the type that we expect them to be, since the
compiler will not be able to figure it out on its own due to other raw
generics.

Change-Id: I605d23ff2c1ed29f5ff512290c22d7f2b73bf23c
diff --git a/user/src/com/google/gwt/editor/rebind/model/ModelUtils.java b/user/src/com/google/gwt/editor/rebind/model/ModelUtils.java
index ae3c397..e9b5dac 100644
--- a/user/src/com/google/gwt/editor/rebind/model/ModelUtils.java
+++ b/user/src/com/google/gwt/editor/rebind/model/ModelUtils.java
@@ -59,7 +59,7 @@
       return (T) maybeParameterized.isRawType().getBaseType();
     }
     if (maybeParameterized.isWildcard() != null) {
-      return (T) maybeParameterized.isWildcard().getBaseType();
+      return ensureBaseType((T) maybeParameterized.isWildcard().getBaseType());
     }
     return maybeParameterized;
   }
diff --git a/user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java b/user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java
index 9fef5da..3505af2 100644
--- a/user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java
+++ b/user/src/com/google/web/bindery/autobean/gwt/rebind/AutoBeanFactoryGenerator.java
@@ -481,6 +481,9 @@
     sw.indent();
     for (AutoBeanMethod method : type.getMethods()) {
       JMethod jmethod = method.getMethod();
+      if (jmethod.isStatic()) {
+        continue;
+      }
       String methodName = jmethod.getName();
       JParameter[] parameters = jmethod.getParameters();
       if (isObjectMethodImplementedByShim(jmethod)) {
@@ -508,9 +511,9 @@
            * The getter call will ensure that any non-value return type is
            * definitely wrapped by an AutoBean instance.
            */
-          sw.println("%s toReturn = %s.this.getWrapped().%s();", ModelUtils
-              .getQualifiedBaseSourceName(jmethod.getReturnType()), type.getSimpleSourceName(),
-              methodName);
+          String getValueType = ModelUtils.getQualifiedBaseSourceName(jmethod.getReturnType());
+          sw.println("%s toReturn = (%s) %s.this.getWrapped().%s();", getValueType, getValueType,
+              type.getSimpleSourceName(), methodName);
 
           // Non-value types might need to be wrapped
           writeReturnWrapper(sw, type, method);
@@ -539,10 +542,10 @@
             sw.println("%s.this.call(\"%s\", null%s %s);", type.getSimpleSourceName(), methodName,
                 arguments.length() > 0 ? "," : "", arguments);
           } else {
-            // Type toReturn = getWrapped().doFoo(params);
-            sw.println("%s toReturn = %s.this.getWrapped().%s(%s);", ModelUtils.ensureBaseType(
-                jmethod.getReturnType()).getQualifiedSourceName(), type.getSimpleSourceName(),
-                methodName, arguments);
+            // Type toReturn = (Type) getWrapped().doFoo(params);
+            String callValueType = ModelUtils.ensureBaseType(jmethod.getReturnType()).getQualifiedSourceName();
+            sw.println("%s toReturn = (%s) %s.this.getWrapped().%s(%s);", callValueType, callValueType,
+                type.getSimpleSourceName(), methodName, arguments);
             // Non-value types might need to be wrapped
             writeReturnWrapper(sw, type, method);
             // call("doFoo", toReturn, params);
diff --git a/user/src/com/google/web/bindery/autobean/gwt/rebind/model/AutoBeanFactoryModel.java b/user/src/com/google/web/bindery/autobean/gwt/rebind/model/AutoBeanFactoryModel.java
index 5981c2f..0701e3a 100644
--- a/user/src/com/google/web/bindery/autobean/gwt/rebind/model/AutoBeanFactoryModel.java
+++ b/user/src/com/google/web/bindery/autobean/gwt/rebind/model/AutoBeanFactoryModel.java
@@ -150,7 +150,7 @@
           continue;
         }
       } else {
-        poison("Unexpecetd parameters in method %s", method.getName());
+        poison("Unexpected parameters in method %s", method.getName());
         continue;
       }