6797463: 6557199 breaks the jax-ws workspace
authortbell
Sat, 24 Jan 2009 11:07:32 -0800
changeset 1874 891c2d6823bb
parent 1873 658385834998
child 1875 6306c60724ee
6797463: 6557199 breaks the jax-ws workspace Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/code/Types.java
langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Jan 23 11:23:10 2009 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Sat Jan 24 11:07:32 2009 -0800
@@ -2933,16 +2933,32 @@
      * Language Specification, Third Ed. (8.4.5)</a>
      */
     public boolean returnTypeSubstitutable(Type r1, Type r2) {
-        return returnTypeSubstitutable(r1, r2, Warner.noWarnings);
-    }
-    //where
-    public boolean returnTypeSubstitutable(Type r1, Type r2, Warner warner) {
         if (hasSameArgs(r1, r2))
-            return resultSubtype(r1, r2, warner);
+            return resultSubtype(r1, r2, Warner.noWarnings);
         else
             return covariantReturnType(r1.getReturnType(),
-                                       r2.getReturnType(),
-                                       warner);
+                                       erasure(r2.getReturnType()),
+                                       Warner.noWarnings);
+    }
+
+    public boolean returnTypeSubstitutable(Type r1,
+                                           Type r2, Type r2res,
+                                           Warner warner) {
+        if (isSameType(r1.getReturnType(), r2res))
+            return true;
+        if (r1.getReturnType().isPrimitive() || r2res.isPrimitive())
+            return false;
+
+        if (hasSameArgs(r1, r2))
+            return covariantReturnType(r1.getReturnType(), r2res, warner);
+        if (!source.allowCovariantReturns())
+            return false;
+        if (isSubtypeUnchecked(r1.getReturnType(), r2res, warner))
+            return true;
+        if (!isSubtype(r1.getReturnType(), erasure(r2res)))
+            return false;
+        warner.warnUnchecked();
+        return true;
     }
 
     /**
@@ -2950,24 +2966,12 @@
      * method that returns s?
      */
     public boolean covariantReturnType(Type t, Type s, Warner warner) {
-        //are return types identical?
-        if (isSameType(t, s))
-            return true;
-        //if t and s are both reference types...
-        else if(source.allowCovariantReturns() &&
+        return
+            isSameType(t, s) ||
+            source.allowCovariantReturns() &&
             !t.isPrimitive() &&
-            !s.isPrimitive()) {
-            //check that t is some unchecked subtype of s
-            if (isSubtypeUnchecked(t, s, warner))
-                return true;
-            //otherwise check that t = |s|
-            else if (isSameType(t, erasure(s))) {
-                warner.warnUnchecked();
-                return true;
-            }
-        }
-        //otherwise t is not return type substitutable for s
-        return false;
+            !s.isPrimitive() &&
+            isAssignable(t, s, warner);
     }
     // </editor-fold>
 
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Jan 23 11:23:10 2009 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Sat Jan 24 11:07:32 2009 -0800
@@ -1163,7 +1163,7 @@
 
         overrideWarner.warned = false;
         boolean resultTypesOK =
-            types.covariantReturnType(mtres, otres, overrideWarner);
+            types.returnTypeSubstitutable(mt, ot, otres, overrideWarner);
         if (!resultTypesOK) {
             if (!source.allowCovariantReturns() &&
                 m.owner != origin &&