From e6ce4c24880ef530517c9d2966dd413ecb242b68 Mon Sep 17 00:00:00 2001 From: Tim Bell Date: Sat, 24 Jan 2009 11:07:32 -0800 Subject: [PATCH] 6797463: 6557199 breaks the jax-ws workspace Reviewed-by: jjg --- .../com/sun/tools/javac/code/Types.java | 52 ++++++++++--------- .../com/sun/tools/javac/comp/Check.java | 2 +- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index d9ba867c534..2a1de89d886 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2933,16 +2933,32 @@ public class Types { * Language Specification, Third Ed. (8.4.5) */ 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 @@ public class Types { * 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); } // diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 12f04a3a5d1..911b9d7d46e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -1163,7 +1163,7 @@ public class Check { overrideWarner.warned = false; boolean resultTypesOK = - types.covariantReturnType(mtres, otres, overrideWarner); + types.returnTypeSubstitutable(mt, ot, otres, overrideWarner); if (!resultTypesOK) { if (!source.allowCovariantReturns() && m.owner != origin &&