1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue May 06 15:46:09 2014 -0600 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri May 09 19:42:25 2014 -0600 1.3 @@ -829,8 +829,9 @@ 1.4 } 1.5 1.6 // Generally, if 's' is a type variable, recur on lower bound; but 1.7 - // for alpha <: CAP, alpha should get upper bound CAP 1.8 - if (!t.hasTag(UNDETVAR)) { 1.9 + // for inference variables and intersections, we need to keep 's' 1.10 + // (see JLS 4.10.2 for intersections and 18.2.3 for inference vars) 1.11 + if (!t.hasTag(UNDETVAR) && !t.isCompound()) { 1.12 // TODO: JDK-8039198, bounds checking sometimes passes in a wildcard as s 1.13 Type lower = cvarLowerBound(wildLowerBound(s)); 1.14 if (s != lower) 1.15 @@ -919,14 +920,11 @@ 1.16 @Override 1.17 public Boolean visitClassType(ClassType t, Type s) { 1.18 Type sup = asSuper(t, s.tsym); 1.19 - return sup != null 1.20 - && sup.tsym == s.tsym 1.21 - // You're not allowed to write 1.22 - // Vector<Object> vec = new Vector<String>(); 1.23 - // But with wildcards you can write 1.24 - // Vector<? extends Object> vec = new Vector<String>(); 1.25 - // which means that subtype checking must be done 1.26 - // here instead of same-type checking (via containsType). 1.27 + if (sup == null) return false; 1.28 + // If t is an intersection, sup might not be a class type 1.29 + if (!sup.hasTag(CLASS)) return isSubtypeNoCapture(sup, s); 1.30 + return sup.tsym == s.tsym 1.31 + // Check type variable containment 1.32 && (!s.isParameterized() || containsTypeRecursive(s, sup)) 1.33 && isSubtypeNoCapture(sup.getEnclosingType(), 1.34 s.getEnclosingType()); 1.35 @@ -1960,16 +1958,18 @@ 1.36 return t; 1.37 1.38 Type st = supertype(t); 1.39 - if (st.hasTag(CLASS) || st.hasTag(TYPEVAR) || st.hasTag(ERROR)) { 1.40 + if (st.hasTag(CLASS) || st.hasTag(TYPEVAR)) { 1.41 Type x = asSuper(st, sym); 1.42 if (x != null) 1.43 return x; 1.44 } 1.45 if ((sym.flags() & INTERFACE) != 0) { 1.46 for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) { 1.47 - Type x = asSuper(l.head, sym); 1.48 - if (x != null) 1.49 - return x; 1.50 + if (!l.head.hasTag(ERROR)) { 1.51 + Type x = asSuper(l.head, sym); 1.52 + if (x != null) 1.53 + return x; 1.54 + } 1.55 } 1.56 } 1.57 return null;