src/share/classes/com/sun/tools/javac/comp/Check.java

changeset 78
77dba8b57346
parent 62
07c916ecfc71
child 79
36df13bde238
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 23 19:55:30 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jul 24 10:35:38 2008 +0100
     1.3 @@ -422,9 +422,7 @@
     1.4       *  @param bs            The bound.
     1.5       */
     1.6      private void checkExtends(DiagnosticPosition pos, Type a, TypeVar bs) {
     1.7 -        if (a.isUnbound()) {
     1.8 -            return;
     1.9 -        } else if (a.tag != WILDCARD) {
    1.10 +        if (!(a instanceof CapturedType)) {
    1.11              a = types.upperBound(a);
    1.12              for (List<Type> l = types.getBounds(bs); l.nonEmpty(); l = l.tail) {
    1.13                  if (!types.isSubtype(a, l.head)) {
    1.14 @@ -432,11 +430,24 @@
    1.15                      return;
    1.16                  }
    1.17              }
    1.18 -        } else if (a.isExtendsBound()) {
    1.19 -            if (!types.isCastable(bs.getUpperBound(), types.upperBound(a), Warner.noWarnings))
    1.20 -                log.error(pos, "not.within.bounds", a);
    1.21 -        } else if (a.isSuperBound()) {
    1.22 -            if (types.notSoftSubtype(types.lowerBound(a), bs.getUpperBound()))
    1.23 +        }
    1.24 +        else {
    1.25 +            CapturedType ct = (CapturedType)a;
    1.26 +            boolean ok = false;
    1.27 +            switch (ct.wildcard.kind) {
    1.28 +                case EXTENDS:
    1.29 +                    ok = types.isCastable(bs.getUpperBound(),
    1.30 +                            types.upperBound(a),
    1.31 +                            Warner.noWarnings);
    1.32 +                    break;
    1.33 +                case SUPER:
    1.34 +                    ok = !types.notSoftSubtype(types.lowerBound(a),
    1.35 +                            bs.getUpperBound());
    1.36 +                    break;
    1.37 +                case UNBOUND:
    1.38 +                    ok = true;
    1.39 +            }
    1.40 +            if (!ok)
    1.41                  log.error(pos, "not.within.bounds", a);
    1.42          }
    1.43      }
    1.44 @@ -776,7 +787,7 @@
    1.45          public void visitTypeApply(JCTypeApply tree) {
    1.46              if (tree.type.tag == CLASS) {
    1.47                  List<Type> formals = tree.type.tsym.type.getTypeArguments();
    1.48 -                List<Type> actuals = tree.type.getTypeArguments();
    1.49 +                List<Type> actuals = types.capture(tree.type).getTypeArguments();
    1.50                  List<JCExpression> args = tree.arguments;
    1.51                  List<Type> forms = formals;
    1.52                  ListBuffer<TypeVar> tvars_buf = new ListBuffer<TypeVar>();
    1.53 @@ -792,7 +803,7 @@
    1.54                      // bounds substed with actuals.
    1.55                      tvars_buf.append(types.substBound(((TypeVar)forms.head),
    1.56                                                        formals,
    1.57 -                                                      Type.removeBounds(actuals)));
    1.58 +                                                      actuals));
    1.59  
    1.60                      args = args.tail;
    1.61                      forms = forms.tail;
    1.62 @@ -811,10 +822,11 @@
    1.63                  tvars = tvars_buf.toList();
    1.64                  while (args.nonEmpty() && tvars.nonEmpty()) {
    1.65                      checkExtends(args.head.pos(),
    1.66 -                                 args.head.type,
    1.67 +                                 actuals.head,
    1.68                                   tvars.head);
    1.69                      args = args.tail;
    1.70                      tvars = tvars.tail;
    1.71 +                    actuals = actuals.tail;
    1.72                  }
    1.73  
    1.74                  // Check that this type is either fully parameterized, or

mercurial