changeset 8455:00d2e017073d

Merge.
author Christian Humer <christian.humer@gmail.com>
date Fri, 22 Mar 2013 18:01:47 +0100
parents fec5ebd058b7 (diff) 3e85441907de (current diff)
children d815f0ac9ed3
files
diffstat 1 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/MethodSubstitutionVerifier.java	Fri Mar 22 09:28:38 2013 -0700
+++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/MethodSubstitutionVerifier.java	Fri Mar 22 18:01:47 2013 +0100
@@ -186,16 +186,21 @@
         return originalMethod;
     }
 
-    private static boolean isTypeCompatible(TypeMirror originalType, TypeMirror substitutionType) {
-        /*
-         * TypeMirrors may contain generic types which deny the types to be equal. So if both types
-         * are declared we erase the generic types by comparing their corresponding declared
-         * element.
-         */
-        if (originalType.getKind() == TypeKind.DECLARED && substitutionType.getKind() == TypeKind.DECLARED) {
-            return ((DeclaredType) originalType).asElement().equals(((DeclaredType) substitutionType).asElement());
+    private boolean isTypeCompatible(TypeMirror originalType, TypeMirror substitutionType) {
+        TypeMirror original = originalType;
+        TypeMirror substitution = substitutionType;
+        if (needsErasure(original)) {
+            original = env.getTypeUtils().erasure(original);
         }
-        return originalType.equals(substitutionType);
+        if (needsErasure(substitution)) {
+            substitution = env.getTypeUtils().erasure(substitution);
+        }
+        return env.getTypeUtils().isSameType(original, substitution);
+    }
+
+    private static boolean needsErasure(TypeMirror typeMirror) {
+        return typeMirror.getKind() != TypeKind.NONE && typeMirror.getKind() != TypeKind.VOID && !typeMirror.getKind().isPrimitive() && typeMirror.getKind() != TypeKind.OTHER &&
+                        typeMirror.getKind() != TypeKind.NULL;
     }
 
     private static TypeElement findEnclosingClass(Element element) {