langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
changeset 938 13aae74ca013
parent 937 457a11ae2e84
child 939 38e24969c7e9
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jul 24 10:35:38 2008 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jul 24 11:12:41 2008 +0100
@@ -422,7 +422,34 @@
      *  @param bs            The bound.
      */
     private void checkExtends(DiagnosticPosition pos, Type a, TypeVar bs) {
-        if (!(a instanceof CapturedType)) {
+        if (a.tag == TYPEVAR && ((TypeVar)a).isCaptured()) {
+            CapturedType ct = (CapturedType)a;
+            boolean ok;
+            if (ct.bound.isErroneous()) {//capture doesn't exist
+                ok = false;
+            }
+            else {
+                switch (ct.wildcard.kind) {
+                    case EXTENDS:
+                        ok = types.isCastable(bs.getUpperBound(),
+                                types.upperBound(a),
+                                Warner.noWarnings);
+                        break;
+                    case SUPER:
+                        ok = !types.notSoftSubtype(types.lowerBound(a),
+                                bs.getUpperBound());
+                        break;
+                    case UNBOUND:
+                        ok = true;
+                        break;
+                    default:
+                        throw new AssertionError("Invalid bound kind");
+                }
+            }
+            if (!ok)
+                log.error(pos, "not.within.bounds", a);
+        }
+        else {
             a = types.upperBound(a);
             for (List<Type> l = types.getBounds(bs); l.nonEmpty(); l = l.tail) {
                 if (!types.isSubtype(a, l.head)) {
@@ -431,25 +458,6 @@
                 }
             }
         }
-        else {
-            CapturedType ct = (CapturedType)a;
-            boolean ok = false;
-            switch (ct.wildcard.kind) {
-                case EXTENDS:
-                    ok = types.isCastable(bs.getUpperBound(),
-                            types.upperBound(a),
-                            Warner.noWarnings);
-                    break;
-                case SUPER:
-                    ok = !types.notSoftSubtype(types.lowerBound(a),
-                            bs.getUpperBound());
-                    break;
-                case UNBOUND:
-                    ok = true;
-            }
-            if (!ok)
-                log.error(pos, "not.within.bounds", a);
-        }
     }
 
     /** Check that type is different from 'void'.