com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext Java Examples

The following examples show how to use com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
        final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
    CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
        MethodCheckDiag methodDiag = varargsCheck ?
                         MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;

        @Override
        public boolean compatible(Type found, Type req, Warner warn) {
            found = pendingInferenceContext.asUndetVar(found);
            if (found.hasTag(UNDETVAR) && req.isPrimitive()) {
                req = types.boxedClass(req).type;
            }
            return super.compatible(found, req, warn);
        }

        @Override
        public void report(DiagnosticPosition pos, JCDiagnostic details) {
            reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
        }
    };
    return new MethodResultInfo(to, checkContext);
}
 
Example #2
Source File: Resolve.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
        final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
    CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
        MethodCheckDiag methodDiag = varargsCheck ?
                         MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;

        @Override
        public boolean compatible(Type found, Type req, Warner warn) {
            found = pendingInferenceContext.asUndetVar(found);
            if (found.hasTag(UNDETVAR) && req.isPrimitive()) {
                req = types.boxedClass(req).type;
            }
            return super.compatible(found, req, warn);
        }

        @Override
        public void report(DiagnosticPosition pos, JCDiagnostic details) {
            reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
        }
    };
    return new MethodResultInfo(to, checkContext);
}
 
Example #3
Source File: ArgumentAttr.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
Type overloadCheck(ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    ResultInfo localInfo = resultInfo.dup(attr.conditionalContext(resultInfo.checkContext));
    if (speculativeTree.isStandalone()) {
        return localInfo.check(speculativeTree, speculativeTree.type);
    } else if (resultInfo.pt.hasTag(VOID)) {
        //this means we are returning a poly conditional from void-compatible lambda expression
        resultInfo.checkContext.report(tree, attr.diags.fragment("conditional.target.cant.be.void"));
        return attr.types.createErrorType(resultInfo.pt);
    } else {
        //poly
        checkSpeculative(speculativeTree.truepart, localInfo);
        checkSpeculative(speculativeTree.falsepart, localInfo);
        return localInfo.pt;
    }
}
 
Example #4
Source File: ArgumentAttr.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
final public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    Assert.check(dt == this);
    if (deferredAttrContext.mode == AttrMode.SPECULATIVE) {
        Type t = (resultInfo.pt == Type.recoveryType) ?
                deferredAttr.basicCompleter.complete(dt, resultInfo, deferredAttrContext) :
                overloadCheck(resultInfo, deferredAttrContext);
        speculativeTypes.put(resultInfo, t);
        return t;
    } else {
        if (!env.info.isSpeculative) {
            argumentTypeCache.remove(new UniquePos(dt.tree));
        }
        return deferredAttr.basicCompleter.complete(dt, resultInfo, deferredAttrContext);
    }
}
 
Example #5
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
        final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
    CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
        MethodCheckDiag methodDiag = varargsCheck ?
                         MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;

        @Override
        public boolean compatible(Type found, Type req, Warner warn) {
            found = pendingInferenceContext.asUndetVar(found);
            if (found.hasTag(UNDETVAR) && req.isPrimitive()) {
                req = types.boxedClass(req).type;
            }
            return super.compatible(found, req, warn);
        }

        @Override
        public void report(DiagnosticPosition pos, JCDiagnostic details) {
            reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
        }
    };
    return new MethodResultInfo(to, checkContext);
}
 
Example #6
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
        final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
    CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
        MethodCheckDiag methodDiag = varargsCheck ?
                         MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;

        @Override
        public boolean compatible(Type found, Type req, Warner warn) {
            found = pendingInferenceContext.asUndetVar(found);
            if (found.hasTag(UNDETVAR) && req.isPrimitive()) {
                req = types.boxedClass(req).type;
            }
            return super.compatible(found, req, warn);
        }

        @Override
        public void report(DiagnosticPosition pos, JCDiagnostic details) {
            reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
        }
    };
    return new MethodResultInfo(to, checkContext);
}
 
Example #7
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
        final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
    CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
        MethodCheckDiag methodDiag = varargsCheck ?
                         MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;

        @Override
        public boolean compatible(Type found, Type req, Warner warn) {
            found = pendingInferenceContext.asUndetVar(found);
            if (found.hasTag(UNDETVAR) && req.isPrimitive()) {
                req = types.boxedClass(req).type;
            }
            return super.compatible(found, req, warn);
        }

        @Override
        public void report(DiagnosticPosition pos, JCDiagnostic details) {
            reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
        }
    };
    return new MethodResultInfo(to, checkContext);
}
 
Example #8
Source File: ArgumentAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
Type overloadCheck(ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    ResultInfo localInfo = resultInfo.dup(attr.conditionalContext(resultInfo.checkContext));
    if (speculativeTree.isStandalone()) {
        return localInfo.check(speculativeTree, speculativeTree.type);
    } else if (resultInfo.pt.hasTag(VOID)) {
        //this means we are returning a poly conditional from void-compatible lambda expression
        resultInfo.checkContext.report(tree, attr.diags.fragment(Fragments.ConditionalTargetCantBeVoid));
        return attr.types.createErrorType(resultInfo.pt);
    } else {
        //poly
        checkSpeculative(speculativeTree.truepart, localInfo);
        checkSpeculative(speculativeTree.falsepart, localInfo);
        return localInfo.pt;
    }
}
 
Example #9
Source File: ArgumentAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
final public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    Assert.check(dt == this);
    if (deferredAttrContext.mode == AttrMode.SPECULATIVE) {
        Type t = (resultInfo.pt == Type.recoveryType) ?
                deferredAttr.basicCompleter.complete(dt, resultInfo, deferredAttrContext) :
                overloadCheck(resultInfo, deferredAttrContext);
        speculativeTypes.put(resultInfo, t);
        return t;
    } else {
        if (!env.info.isSpeculative) {
            argumentTypeCache.remove(new UniquePos(dt.tree));
        }
        return deferredAttr.basicCompleter.complete(dt, resultInfo, deferredAttrContext);
    }
}
 
Example #10
Source File: Resolve.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) {
    DeferredAttrContext parent = (pendingResult == null)
        ? deferredAttr.emptyDeferredAttrContext
        : pendingResult.checkContext.deferredAttrContext();
    return deferredAttr.new DeferredAttrContext(attrMode, sym, step,
            inferenceContext, parent, warn);
}
 
Example #11
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void argumentsAcceptable(final Env<AttrContext> env,
                            DeferredAttrContext deferredAttrContext,
                            List<Type> formals1,
                            List<Type> formals2,
                            Warner warn) {
    formals2 = adjustArgs(formals2, deferredAttrContext.msym, formals1.length(), deferredAttrContext.phase.isVarargsRequired());
    while (formals2.nonEmpty()) {
        ResultInfo mresult = methodCheckResult(formals2.head, deferredAttrContext, warn, actuals.head);
        mresult.check(null, formals1.head);
        formals1 = formals1.tail;
        formals2 = formals2.tail;
        actuals = actuals.isEmpty() ? actuals : actuals.tail;
    }
}
 
Example #12
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void argumentsAcceptable(final Env<AttrContext> env,
                            DeferredAttrContext deferredAttrContext,
                            List<Type> formals1,
                            List<Type> formals2,
                            Warner warn) {
    formals2 = adjustArgs(formals2, deferredAttrContext.msym, formals1.length(), deferredAttrContext.phase.isVarargsRequired());
    while (formals2.nonEmpty()) {
        ResultInfo mresult = methodCheckResult(formals2.head, deferredAttrContext, warn, actuals.head);
        mresult.check(null, formals1.head);
        formals1 = formals1.tail;
        formals2 = formals2.tail;
        actuals = actuals.isEmpty() ? actuals : actuals.tail;
    }
}
 
Example #13
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) {
    DeferredAttrContext parent = (pendingResult == null)
        ? deferredAttr.emptyDeferredAttrContext
        : pendingResult.checkContext.deferredAttrContext();
    return deferredAttr.new DeferredAttrContext(attrMode, sym, step,
            inferenceContext, parent, warn);
}
 
Example #14
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) {
    DeferredAttrContext parent = (pendingResult == null)
        ? deferredAttr.emptyDeferredAttrContext
        : pendingResult.checkContext.deferredAttrContext();
    return deferredAttr.new DeferredAttrContext(attrMode, sym, step,
            inferenceContext, parent, warn);
}
 
Example #15
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void argumentsAcceptable(final Env<AttrContext> env,
                            DeferredAttrContext deferredAttrContext,
                            List<Type> formals1,
                            List<Type> formals2,
                            Warner warn) {
    formals2 = adjustArgs(formals2, deferredAttrContext.msym, formals1.length(), deferredAttrContext.phase.isVarargsRequired());
    while (formals2.nonEmpty()) {
        ResultInfo mresult = methodCheckResult(formals2.head, deferredAttrContext, warn, actuals.head);
        mresult.check(null, formals1.head);
        formals1 = formals1.tail;
        formals2 = formals2.tail;
        actuals = actuals.isEmpty() ? actuals : actuals.tail;
    }
}
 
Example #16
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) {
    DeferredAttrContext parent = (pendingResult == null)
        ? deferredAttr.emptyDeferredAttrContext
        : pendingResult.checkContext.deferredAttrContext();
    return deferredAttr.new DeferredAttrContext(attrMode, sym, step,
            inferenceContext, parent, warn);
}
 
Example #17
Source File: ArgumentAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
Type overloadCheck(ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    try {
        //compute target-type; this logic could be shared with Attr
        TargetInfo targetInfo = attr.getTargetInfo(speculativeTree, resultInfo, argtypes());
        Type lambdaType = targetInfo.descriptor;
        Type currentTarget = targetInfo.target;
        //check compatibility
        checkLambdaCompatible(lambdaType, resultInfo);
        return currentTarget;
    } catch (FunctionDescriptorLookupError ex) {
        resultInfo.checkContext.report(null, ex.getDiagnostic());
        return null; //cannot get here
    }
}
 
Example #18
Source File: ArgumentAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
Type overloadCheck(ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    Type mtype = methodType();
    ResultInfo localInfo = resultInfo(resultInfo);
    Type t;
    if (mtype != null && mtype.hasTag(METHOD) && mtype.isPartial()) {
        //poly invocation
        t = ((PartiallyInferredMethodType)mtype).check(localInfo);
    } else {
        //standalone invocation
        t = localInfo.check(tree.pos(), speculativeTree.type);
    }
    speculativeTypes.put(localInfo, t);
    return t;
}
 
Example #19
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void argumentsAcceptable(final Env<AttrContext> env,
                            DeferredAttrContext deferredAttrContext,
                            List<Type> formals1,
                            List<Type> formals2,
                            Warner warn) {
    formals2 = adjustArgs(formals2, deferredAttrContext.msym, formals1.length(), deferredAttrContext.phase.isVarargsRequired());
    while (formals2.nonEmpty()) {
        ResultInfo mresult = methodCheckResult(formals2.head, deferredAttrContext, warn, actuals.head);
        mresult.check(null, formals1.head);
        formals1 = formals1.tail;
        formals2 = formals2.tail;
        actuals = actuals.isEmpty() ? actuals : actuals.tail;
    }
}
 
Example #20
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) {
    DeferredAttrContext parent = (pendingResult == null)
        ? deferredAttr.emptyDeferredAttrContext
        : pendingResult.checkContext.deferredAttrContext();
    return deferredAttr.new DeferredAttrContext(attrMode, sym, step,
            inferenceContext, parent, warn);
}
 
Example #21
Source File: ArgumentAttr.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
Type speculativeType(Symbol msym, MethodResolutionPhase phase) {
    if (pertinentToApplicability) {
        for (Map.Entry<ResultInfo, Type> _entry : speculativeTypes.entrySet()) {
            DeferredAttrContext deferredAttrContext = _entry.getKey().checkContext.deferredAttrContext();
            if (deferredAttrContext.phase == phase && deferredAttrContext.msym == msym) {
                return _entry.getValue();
            }
        }
        return Type.noType;
    } else {
        return super.speculativeType(msym, phase);
    }
}
 
Example #22
Source File: ArgumentAttr.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
Type overloadCheck(ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    try {
        //compute target-type; this logic could be shared with Attr
        TargetInfo targetInfo = attr.getTargetInfo(speculativeTree, resultInfo, argtypes());
        Type lambdaType = targetInfo.descriptor;
        Type currentTarget = targetInfo.target;
        //check compatibility
        checkLambdaCompatible(lambdaType, resultInfo);
        return currentTarget;
    } catch (FunctionDescriptorLookupError ex) {
        resultInfo.checkContext.report(null, ex.getDiagnostic());
        return null; //cannot get here
    }
}
 
Example #23
Source File: Resolve.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void argumentsAcceptable(final Env<AttrContext> env,
                            DeferredAttrContext deferredAttrContext,
                            List<Type> formals1,
                            List<Type> formals2,
                            Warner warn) {
    formals2 = adjustArgs(formals2, deferredAttrContext.msym, formals1.length(), deferredAttrContext.phase.isVarargsRequired());
    while (formals2.nonEmpty()) {
        ResultInfo mresult = methodCheckResult(formals2.head, deferredAttrContext, warn, actuals.head);
        mresult.check(null, formals1.head);
        formals1 = formals1.tail;
        formals2 = formals2.tail;
        actuals = actuals.isEmpty() ? actuals : actuals.tail;
    }
}
 
Example #24
Source File: ArgumentAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
Type speculativeType(Symbol msym, MethodResolutionPhase phase) {
    if (pertinentToApplicability) {
        for (Map.Entry<ResultInfo, Type> _entry : speculativeTypes.entrySet()) {
            DeferredAttrContext deferredAttrContext = _entry.getKey().checkContext.deferredAttrContext();
            if (deferredAttrContext.phase == phase && deferredAttrContext.msym == msym) {
                return _entry.getValue();
            }
        }
        return Type.noType;
    } else {
        return super.speculativeType(msym, phase);
    }
}
 
Example #25
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
    ResultInfo mresult = methodCheckResult(varargs, formal, deferredAttrContext, warn);
    mresult.check(pos, actual);
}
 
Example #26
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public DeferredAttrContext deferredAttrContext() {
    return deferredAttrContext;
}
 
Example #27
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public MethodCheckContext(boolean strict, DeferredAttrContext deferredAttrContext, Warner rsWarner) {
   this.strict = strict;
   this.deferredAttrContext = deferredAttrContext;
   this.rsWarner = rsWarner;
}
 
Example #28
Source File: Check.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public DeferredAttrContext deferredAttrContext() {
    return enclosingContext.deferredAttrContext();
}
 
Example #29
Source File: Resolve.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
    ResultInfo mresult = methodCheckResult(varargs, formal, deferredAttrContext, warn);
    mresult.check(pos, actual);
}
 
Example #30
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public MethodCheckContext(boolean strict, DeferredAttrContext deferredAttrContext, Warner rsWarner) {
   this.strict = strict;
   this.deferredAttrContext = deferredAttrContext;
   this.rsWarner = rsWarner;
}