diff -r 327122b01a9e -r 856d94394294 src/share/classes/com/sun/tools/javac/code/Types.java --- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue May 06 15:46:09 2014 -0600 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri May 09 19:42:25 2014 -0600 @@ -829,8 +829,9 @@ } // Generally, if 's' is a type variable, recur on lower bound; but - // for alpha <: CAP, alpha should get upper bound CAP - if (!t.hasTag(UNDETVAR)) { + // for inference variables and intersections, we need to keep 's' + // (see JLS 4.10.2 for intersections and 18.2.3 for inference vars) + if (!t.hasTag(UNDETVAR) && !t.isCompound()) { // TODO: JDK-8039198, bounds checking sometimes passes in a wildcard as s Type lower = cvarLowerBound(wildLowerBound(s)); if (s != lower) @@ -919,14 +920,11 @@ @Override public Boolean visitClassType(ClassType t, Type s) { Type sup = asSuper(t, s.tsym); - return sup != null - && sup.tsym == s.tsym - // You're not allowed to write - // Vector vec = new Vector(); - // But with wildcards you can write - // Vector vec = new Vector(); - // which means that subtype checking must be done - // here instead of same-type checking (via containsType). + if (sup == null) return false; + // If t is an intersection, sup might not be a class type + if (!sup.hasTag(CLASS)) return isSubtypeNoCapture(sup, s); + return sup.tsym == s.tsym + // Check type variable containment && (!s.isParameterized() || containsTypeRecursive(s, sup)) && isSubtypeNoCapture(sup.getEnclosingType(), s.getEnclosingType()); @@ -1960,16 +1958,18 @@ return t; Type st = supertype(t); - if (st.hasTag(CLASS) || st.hasTag(TYPEVAR) || st.hasTag(ERROR)) { + if (st.hasTag(CLASS) || st.hasTag(TYPEVAR)) { Type x = asSuper(st, sym); if (x != null) return x; } if ((sym.flags() & INTERFACE) != 0) { for (List l = interfaces(t); l.nonEmpty(); l = l.tail) { - Type x = asSuper(l.head, sym); - if (x != null) - return x; + if (!l.head.hasTag(ERROR)) { + Type x = asSuper(l.head, sym); + if (x != null) + return x; + } } } return null;