1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Oct 06 18:39:31 2011 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Mon Oct 17 12:54:33 2011 +0100 1.3 @@ -278,7 +278,6 @@ 1.4 boolean tPrimitive = t.isPrimitive(); 1.5 boolean sPrimitive = s.isPrimitive(); 1.6 if (tPrimitive == sPrimitive) { 1.7 - checkUnsafeVarargsConversion(t, s, warn); 1.8 return isSubtypeUnchecked(t, s, warn); 1.9 } 1.10 if (!allowBoxing) return false; 1.11 @@ -286,27 +285,6 @@ 1.12 ? isSubtype(boxedClass(t).type, s) 1.13 : isSubtype(unboxedType(t), s); 1.14 } 1.15 - //where 1.16 - private void checkUnsafeVarargsConversion(Type t, Type s, Warner warn) { 1.17 - if (t.tag != ARRAY || isReifiable(t)) return; 1.18 - ArrayType from = (ArrayType)t; 1.19 - boolean shouldWarn = false; 1.20 - switch (s.tag) { 1.21 - case ARRAY: 1.22 - ArrayType to = (ArrayType)s; 1.23 - shouldWarn = from.isVarargs() && 1.24 - !to.isVarargs() && 1.25 - !isReifiable(from); 1.26 - break; 1.27 - case CLASS: 1.28 - shouldWarn = from.isVarargs() && 1.29 - isSubtype(from, s); 1.30 - break; 1.31 - } 1.32 - if (shouldWarn) { 1.33 - warn.warn(LintCategory.VARARGS); 1.34 - } 1.35 - } 1.36 1.37 /** 1.38 * Is t a subtype of or convertiable via boxing/unboxing 1.39 @@ -328,42 +306,63 @@ 1.40 * Is t an unchecked subtype of s? 1.41 */ 1.42 public boolean isSubtypeUnchecked(Type t, Type s, Warner warn) { 1.43 - if (t.tag == ARRAY && s.tag == ARRAY) { 1.44 - if (((ArrayType)t).elemtype.tag <= lastBaseTag) { 1.45 - return isSameType(elemtype(t), elemtype(s)); 1.46 - } else { 1.47 - ArrayType from = (ArrayType)t; 1.48 - ArrayType to = (ArrayType)s; 1.49 - if (from.isVarargs() && 1.50 - !to.isVarargs() && 1.51 - !isReifiable(from)) { 1.52 - warn.warn(LintCategory.VARARGS); 1.53 + boolean result = isSubtypeUncheckedInternal(t, s, warn); 1.54 + if (result) { 1.55 + checkUnsafeVarargsConversion(t, s, warn); 1.56 + } 1.57 + return result; 1.58 + } 1.59 + //where 1.60 + private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) { 1.61 + if (t.tag == ARRAY && s.tag == ARRAY) { 1.62 + if (((ArrayType)t).elemtype.tag <= lastBaseTag) { 1.63 + return isSameType(elemtype(t), elemtype(s)); 1.64 + } else { 1.65 + return isSubtypeUnchecked(elemtype(t), elemtype(s), warn); 1.66 } 1.67 - return isSubtypeUnchecked(elemtype(t), elemtype(s), warn); 1.68 - } 1.69 - } else if (isSubtype(t, s)) { 1.70 - return true; 1.71 - } 1.72 - else if (t.tag == TYPEVAR) { 1.73 - return isSubtypeUnchecked(t.getUpperBound(), s, warn); 1.74 - } 1.75 - else if (s.tag == UNDETVAR) { 1.76 - UndetVar uv = (UndetVar)s; 1.77 - if (uv.inst != null) 1.78 - return isSubtypeUnchecked(t, uv.inst, warn); 1.79 - } 1.80 - else if (!s.isRaw()) { 1.81 - Type t2 = asSuper(t, s.tsym); 1.82 - if (t2 != null && t2.isRaw()) { 1.83 - if (isReifiable(s)) 1.84 - warn.silentWarn(LintCategory.UNCHECKED); 1.85 - else 1.86 - warn.warn(LintCategory.UNCHECKED); 1.87 + } else if (isSubtype(t, s)) { 1.88 return true; 1.89 } 1.90 + else if (t.tag == TYPEVAR) { 1.91 + return isSubtypeUnchecked(t.getUpperBound(), s, warn); 1.92 + } 1.93 + else if (s.tag == UNDETVAR) { 1.94 + UndetVar uv = (UndetVar)s; 1.95 + if (uv.inst != null) 1.96 + return isSubtypeUnchecked(t, uv.inst, warn); 1.97 + } 1.98 + else if (!s.isRaw()) { 1.99 + Type t2 = asSuper(t, s.tsym); 1.100 + if (t2 != null && t2.isRaw()) { 1.101 + if (isReifiable(s)) 1.102 + warn.silentWarn(LintCategory.UNCHECKED); 1.103 + else 1.104 + warn.warn(LintCategory.UNCHECKED); 1.105 + return true; 1.106 + } 1.107 + } 1.108 + return false; 1.109 } 1.110 - return false; 1.111 - } 1.112 + 1.113 + private void checkUnsafeVarargsConversion(Type t, Type s, Warner warn) { 1.114 + if (t.tag != ARRAY || isReifiable(t)) return; 1.115 + ArrayType from = (ArrayType)t; 1.116 + boolean shouldWarn = false; 1.117 + switch (s.tag) { 1.118 + case ARRAY: 1.119 + ArrayType to = (ArrayType)s; 1.120 + shouldWarn = from.isVarargs() && 1.121 + !to.isVarargs() && 1.122 + !isReifiable(from); 1.123 + break; 1.124 + case CLASS: 1.125 + shouldWarn = from.isVarargs(); 1.126 + break; 1.127 + } 1.128 + if (shouldWarn) { 1.129 + warn.warn(LintCategory.VARARGS); 1.130 + } 1.131 + } 1.132 1.133 /** 1.134 * Is t a subtype of s?<br>