langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java
changeset 43025 b6e87a8600a4
parent 42973 3795332b55c7
child 44186 fe848a208b20
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Wed Jul 05 22:39:06 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Tue Jan 03 16:27:54 2017 -0700
@@ -3845,20 +3845,26 @@
             return bounds.head;
         } else {                            // length > 1
             int classCount = 0;
+            List<Type> cvars = List.nil();
             List<Type> lowers = List.nil();
             for (Type bound : bounds) {
                 if (!bound.isInterface()) {
                     classCount++;
                     Type lower = cvarLowerBound(bound);
-                    if (bound != lower && !lower.hasTag(BOT))
-                        lowers = insert(lowers, lower);
+                    if (bound != lower && !lower.hasTag(BOT)) {
+                        cvars = cvars.append(bound);
+                        lowers = lowers.append(lower);
+                    }
                 }
             }
             if (classCount > 1) {
-                if (lowers.isEmpty())
+                if (lowers.isEmpty()) {
                     return createErrorType(errT);
-                else
-                    return glbFlattened(union(bounds, lowers), errT);
+                } else {
+                    // try again with lower bounds included instead of capture variables
+                    List<Type> newBounds = bounds.diff(cvars).appendList(lowers);
+                    return glb(newBounds);
+                }
             }
         }
         return makeIntersectionType(bounds);