nashorn/src/jdk/nashorn/internal/runtime/CompiledFunctions.java
changeset 24759 31aed7d9c02a
parent 24740 26791be09688
--- a/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunctions.java	Thu May 15 15:28:51 2014 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunctions.java	Mon May 19 15:29:42 2014 +0200
@@ -63,6 +63,14 @@
         return '\'' + name + "' code=" + functions;
     }
 
+    private static MethodType widen(final MethodType cftype) {
+        final Class<?>[] paramTypes = new Class<?>[cftype.parameterCount()];
+        for (int i = 0; i < cftype.parameterCount(); i++) {
+            paramTypes[i] = cftype.parameterType(i).isPrimitive() ? cftype.parameterType(i) : Object.class;
+        }
+        return MH.type(cftype.returnType(), paramTypes);
+    }
+
     /**
      * Used to find an apply to call version that fits this callsite.
      * We cannot just, as in the normal matcher case, return e.g. (Object, Object, int)
@@ -82,15 +90,10 @@
                 continue;
             }
 
-            final Class<?>[] paramTypes = new Class<?>[cftype.parameterCount()];
-            for (int i = 0; i < cftype.parameterCount(); i++) {
-                paramTypes[i] = cftype.parameterType(i).isPrimitive() ? cftype.parameterType(i) : Object.class;
-            }
-
-            if (MH.type(cftype.returnType(), paramTypes).equals(type)) {
+            if (widen(cftype).equals(widen(type))) {
                 return cf;
             }
-        }
+         }
 
         return null;
     }