Reviewers: scottb,

Description:
Fixes two DevMode issues:
1 - Generic SingleImplJso interfaces are now mapped by their
JGenericType in
TypeOracle instead of their JParameterizedType since lookups in DevMode
will use the generic type.
2 - Fixes a bug in CompilingClassLoader where SingleImplJso interfaces
would
have their methods mapped to the left JSO impl and not the actual
declaring type for the method.

Review by: sco...@google.com

Please review this at http://gwt-code-reviews.appspot.com/1140801/show

Affected files:
  M dev/core/src/com/google/gwt/core/ext/typeinfo/JAbstractMethod.java
  M dev/core/src/com/google/gwt/core/ext/typeinfo/TypeOracle.java
  M dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java


Index: dev/core/src/com/google/gwt/core/ext/typeinfo/JAbstractMethod.java
===================================================================
--- dev/core/src/com/google/gwt/core/ext/typeinfo/JAbstractMethod.java (revision 9262) +++ dev/core/src/com/google/gwt/core/ext/typeinfo/JAbstractMethod.java (working copy)
@@ -113,6 +113,14 @@
   public JType[] getThrows() {
     return thrownTypes.toArray(TypeOracle.NO_JTYPES);
   }
+
+  public JType[] getParameterTypes() {
+    final JType[] paramTypes = new JType[params.size()];
+    for (int i = 0; i < paramTypes.length; ++i) {
+      paramTypes[i] = params.get(i).getType();
+    }
+    return paramTypes;
+  }

   public JTypeParameter[] getTypeParameters() {
     return typeParams.toArray(new JTypeParameter[typeParams.size()]);
Index: dev/core/src/com/google/gwt/core/ext/typeinfo/TypeOracle.java
===================================================================
--- dev/core/src/com/google/gwt/core/ext/typeinfo/TypeOracle.java (revision 9262) +++ dev/core/src/com/google/gwt/core/ext/typeinfo/TypeOracle.java (working copy)
@@ -716,6 +716,12 @@
       }

for (JClassType intf : JClassType.getFlattenedSuperTypeHierarchy(type)) { + // If intf refers to a JParameterizedType, we need to use its generic
+        // base type instead.
+        if (intf instanceof JParameterizedType) {
+          intf = ((JParameterizedType)intf).getBaseType();
+        }
+
         if (intf.isInterface() == null) {
           // Not an interface
           continue;
Index: dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
===================================================================
--- dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java (revision 9262) +++ dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java (working copy)
@@ -361,7 +361,7 @@
   private class MyInstanceMethodOracle implements InstanceMethodOracle {

private final Map<String, Set<JClassType>> signatureToDeclaringClasses = new HashMap<String, Set<JClassType>>();
-
+
     public MyInstanceMethodOracle(Set<JClassType> jsoTypes,
         JClassType javaLangObject, SingleJsoImplData jsoData) {

@@ -387,7 +387,11 @@
JClassType intf = typeOracle.findType(Name.InternalName.toSourceName(intfName));
         JClassType jso = typeOracle.getSingleJsoImpl(intf);
         for (JMethod method : intf.getMethods()) {
-          add(jso, method);
+          JClassType implementingJso = findImplementingTypeForMethod(jso,
+              method.getName(), method.getParameterTypes());
+          assert implementingJso != null
+            : "Jso should contain method: " + method.getJsniSignature();
+          add(implementingJso, method);
         }
       }

@@ -790,6 +794,14 @@
     }
   }

+ private static JClassType findImplementingTypeForMethod(JClassType type, String name, JType[] params) {
+    if (type == null) {
+      return null;
+    }
+    JMethod method = type.findMethod(name, params);
+ return method != null ? type : findImplementingTypeForMethod(type.getSuperclass(), name, params);
+  }
+
   private static byte[] getClassBytesFromStream(InputStream is)
       throws IOException {
     try {


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to