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

changeset 2535
4b4841501dd9
parent 2531
fc2a01ba3d79
child 2543
c6d5efccedc3
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jun 27 20:32:12 2014 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jul 04 16:34:44 2014 +0100
     1.3 @@ -96,7 +96,7 @@
     1.4      public final boolean varargsEnabled;
     1.5      public final boolean allowMethodHandles;
     1.6      public final boolean allowFunctionalInterfaceMostSpecific;
     1.7 -    public final boolean checkVarargsAccessDuringResolution;
     1.8 +    public final boolean checkVarargsAccessAfterResolution;
     1.9      private final boolean debugResolve;
    1.10      private final boolean compactMethodDiags;
    1.11      final EnumSet<VerboseResolutionMode> verboseResolutionMode;
    1.12 @@ -138,7 +138,7 @@
    1.13          Target target = Target.instance(context);
    1.14          allowMethodHandles = target.hasMethodHandles();
    1.15          allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific();
    1.16 -        checkVarargsAccessDuringResolution =
    1.17 +        checkVarargsAccessAfterResolution =
    1.18                  source.allowPostApplicabilityVarargsAccessCheck();
    1.19          polymorphicSignatureScope = new Scope(syms.noSymbol);
    1.20  
    1.21 @@ -837,13 +837,16 @@
    1.22                                      Warner warn) {
    1.23              super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn);
    1.24              //should we expand formals?
    1.25 -            if ((!checkVarargsAccessDuringResolution ||
    1.26 -                (checkVarargsAccessDuringResolution &&
    1.27 -                 deferredAttrContext.mode == AttrMode.CHECK)) &&
    1.28 -                deferredAttrContext.phase.isVarargsRequired()) {
    1.29 -                //check varargs element type accessibility
    1.30 -                varargsAccessible(env, types.elemtype(formals.last()),
    1.31 -                        deferredAttrContext.inferenceContext);
    1.32 +            if (deferredAttrContext.phase.isVarargsRequired()) {
    1.33 +                Type typeToCheck = null;
    1.34 +                if (!checkVarargsAccessAfterResolution) {
    1.35 +                    typeToCheck = types.elemtype(formals.last());
    1.36 +                } else if (deferredAttrContext.mode == AttrMode.CHECK) {
    1.37 +                    typeToCheck = types.erasure(types.elemtype(formals.last()));
    1.38 +                }
    1.39 +                if (typeToCheck != null) {
    1.40 +                    varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext);
    1.41 +                }
    1.42              }
    1.43          }
    1.44  

mercurial