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

changeset 1347
1408af4cd8b0
parent 1344
73312ec2cf7c
child 1348
573ceb23beeb
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Sat Sep 29 09:00:58 2012 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Oct 04 13:04:53 2012 +0100
     1.3 @@ -40,6 +40,7 @@
     1.4  import com.sun.tools.javac.code.Lint.LintCategory;
     1.5  import com.sun.tools.javac.code.Type.*;
     1.6  import com.sun.tools.javac.code.Symbol.*;
     1.7 +import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext;
     1.8  import com.sun.tools.javac.comp.Infer.InferenceContext;
     1.9  import com.sun.tools.javac.comp.Infer.InferenceContext.FreeTypeListener;
    1.10  
    1.11 @@ -68,6 +69,7 @@
    1.12      private final Resolve rs;
    1.13      private final Symtab syms;
    1.14      private final Enter enter;
    1.15 +    private final DeferredAttr deferredAttr;
    1.16      private final Infer infer;
    1.17      private final Types types;
    1.18      private final JCDiagnostic.Factory diags;
    1.19 @@ -100,6 +102,7 @@
    1.20          rs = Resolve.instance(context);
    1.21          syms = Symtab.instance(context);
    1.22          enter = Enter.instance(context);
    1.23 +        deferredAttr = DeferredAttr.instance(context);
    1.24          infer = Infer.instance(context);
    1.25          this.types = Types.instance(context);
    1.26          diags = JCDiagnostic.Factory.instance(context);
    1.27 @@ -433,6 +436,8 @@
    1.28          public Warner checkWarner(DiagnosticPosition pos, Type found, Type req);
    1.29  
    1.30          public Infer.InferenceContext inferenceContext();
    1.31 +
    1.32 +        public DeferredAttr.DeferredAttrContext deferredAttrContext();
    1.33      }
    1.34  
    1.35      /**
    1.36 @@ -463,6 +468,10 @@
    1.37          public Infer.InferenceContext inferenceContext() {
    1.38              return enclosingContext.inferenceContext();
    1.39          }
    1.40 +
    1.41 +        public DeferredAttrContext deferredAttrContext() {
    1.42 +            return enclosingContext.deferredAttrContext();
    1.43 +        }
    1.44      }
    1.45  
    1.46      /**
    1.47 @@ -483,6 +492,10 @@
    1.48          public InferenceContext inferenceContext() {
    1.49              return infer.emptyContext;
    1.50          }
    1.51 +
    1.52 +        public DeferredAttrContext deferredAttrContext() {
    1.53 +            return deferredAttr.emptyDeferredAttrContext;
    1.54 +        }
    1.55      };
    1.56  
    1.57      /** Check that a given type is assignable to a given proto-type.
    1.58 @@ -817,6 +830,8 @@
    1.59                  sym.owner == syms.enumSym)
    1.60                  formals = formals.tail.tail;
    1.61          List<JCExpression> args = argtrees;
    1.62 +        DeferredAttr.DeferredTypeMap checkDeferredMap =
    1.63 +                deferredAttr.new DeferredTypeMap(DeferredAttr.AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
    1.64          while (formals.head != last) {
    1.65              JCTree arg = args.head;
    1.66              Warner warn = convertWarner(arg.pos(), arg.type, formals.head);
    1.67 @@ -835,7 +850,7 @@
    1.68          } else if ((sym.flags() & VARARGS) != 0 && allowVarargs) {
    1.69              // non-varargs call to varargs method
    1.70              Type varParam = owntype.getParameterTypes().last();
    1.71 -            Type lastArg = argtypes.last();
    1.72 +            Type lastArg = checkDeferredMap.apply(argtypes.last());
    1.73              if (types.isSubtypeUnchecked(lastArg, types.elemtype(varParam)) &&
    1.74                      !types.isSameType(types.erasure(varParam), types.erasure(lastArg)))
    1.75                  log.warning(argtrees.last().pos(), "inexact.non-varargs.call",
    1.76 @@ -847,7 +862,7 @@
    1.77                      kindName(sym),
    1.78                      sym.name,
    1.79                      rs.methodArguments(sym.type.getParameterTypes()),
    1.80 -                    rs.methodArguments(argtypes),
    1.81 +                    rs.methodArguments(Type.map(argtypes, checkDeferredMap)),
    1.82                      kindName(sym.location()),
    1.83                      sym.location());
    1.84             owntype = new MethodType(owntype.getParameterTypes(),

mercurial