com.sun.tools.javac.comp.Infer.InferenceContext Java Examples

The following examples show how to use com.sun.tools.javac.comp.Infer.InferenceContext. 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: DeferredAttr.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
        InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
    this.mode = mode;
    this.msym = msym;
    this.phase = phase;
    this.parent = parent;
    this.warn = warn;
    this.inferenceContext = inferenceContext;
}
 
Example #2
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
    if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
            argtypes.nonEmpty() &&
            (argtypes.head.hasTag(NONE) ||
            types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) {
        return new UnboundMethodReferenceLookupHelper(referenceTree, name,
                site, argtypes, typeargtypes, maxPhase);
    } else {
        return super.unboundLookup(inferenceContext);
    }
}
 
Example #3
Source File: DeferredAttr.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
        InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
    this.mode = mode;
    this.msym = msym;
    this.phase = phase;
    this.parent = parent;
    this.warn = warn;
    this.inferenceContext = inferenceContext;
}
 
Example #4
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 #5
Source File: Resolve.java    From hottub 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 #6
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
    boolean inferDiag = inferenceContext != infer.emptyContext;
    InapplicableMethodException ex = inferDiag ?
            infer.inferenceException : inapplicableMethodException;
    if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
        Object[] args2 = new Object[args.length + 1];
        System.arraycopy(args, 0, args2, 1, args.length);
        args2[0] = inferenceContext.inferenceVars();
        args = args2;
    }
    String key = inferDiag ? diag.inferKey : diag.basicKey;
    throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
}
 
Example #7
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 #8
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
    if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
            argtypes.nonEmpty() &&
            (argtypes.head.hasTag(NONE) ||
            types.isSubtypeUnchecked(inferenceContext.asFree(argtypes.head), site))) {
        return new UnboundMethodReferenceLookupHelper(referenceTree, name,
                site, argtypes, typeargtypes, maxPhase);
    } else {
        return super.unboundLookup(inferenceContext);
    }
}
 
Example #9
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
    if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
            argtypes.nonEmpty() &&
            (argtypes.head.hasTag(NONE) ||
            types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) {
        return new UnboundMethodReferenceLookupHelper(referenceTree, name,
                site, argtypes, typeargtypes, maxPhase);
    } else {
        return super.unboundLookup(inferenceContext);
    }
}
 
Example #10
Source File: DeferredAttr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
        InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
    this.mode = mode;
    this.msym = msym;
    this.phase = phase;
    this.parent = parent;
    this.warn = warn;
    this.inferenceContext = inferenceContext;
}
 
Example #11
Source File: DeferredAttr.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
        InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
    this.mode = mode;
    this.msym = msym;
    this.phase = phase;
    this.parent = parent;
    this.warn = warn;
    this.inferenceContext = inferenceContext;
}
 
Example #12
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
    boolean inferDiag = inferenceContext != infer.emptyContext;
    InapplicableMethodException ex = inferDiag ?
            infer.inferenceException : inapplicableMethodException;
    if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
        Object[] args2 = new Object[args.length + 1];
        System.arraycopy(args, 0, args2, 1, args.length);
        args2[0] = inferenceContext.inferenceVars();
        args = args2;
    }
    String key = inferDiag ? diag.inferKey : diag.basicKey;
    throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
}
 
Example #13
Source File: DeferredAttr.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
        InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
    this.mode = mode;
    this.msym = msym;
    this.phase = phase;
    this.parent = parent;
    this.warn = warn;
    this.inferenceContext = inferenceContext;
}
 
Example #14
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
    boolean inferDiag = inferenceContext != infer.emptyContext;
    InapplicableMethodException ex = inferDiag ?
            infer.inferenceException : inapplicableMethodException;
    if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
        Object[] args2 = new Object[args.length + 1];
        System.arraycopy(args, 0, args2, 1, args.length);
        args2[0] = inferenceContext.inferenceVars();
        args = args2;
    }
    String key = inferDiag ? diag.inferKey : diag.basicKey;
    throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
}
 
Example #15
Source File: Resolve.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
    boolean inferDiag = inferenceContext != infer.emptyContext;
    InapplicableMethodException ex = inferDiag ?
            infer.inferenceException : inapplicableMethodException;
    if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
        Object[] args2 = new Object[args.length + 1];
        System.arraycopy(args, 0, args2, 1, args.length);
        args2[0] = inferenceContext.inferenceVars();
        args = args2;
    }
    String key = inferDiag ? diag.inferKey : diag.basicKey;
    throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
}
 
Example #16
Source File: DeferredAttr.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
        InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
    this.mode = mode;
    this.msym = msym;
    this.phase = phase;
    this.parent = parent;
    this.warn = warn;
    this.inferenceContext = inferenceContext;
}
 
Example #17
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
    boolean inferDiag = inferenceContext != infer.emptyContext;
    InapplicableMethodException ex = inferDiag ?
            infer.inferenceException : inapplicableMethodException;
    if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
        Object[] args2 = new Object[args.length + 1];
        System.arraycopy(args, 0, args2, 1, args.length);
        args2[0] = inferenceContext.inferenceVars();
        args = args2;
    }
    String key = inferDiag ? diag.inferKey : diag.basicKey;
    throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
}
 
Example #18
Source File: DeferredAttr.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
        InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
    this.mode = mode;
    this.msym = msym;
    this.phase = phase;
    this.parent = parent;
    this.warn = warn;
    this.inferenceContext = inferenceContext;
}
 
Example #19
Source File: Resolve.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
    boolean inferDiag = inferenceContext != infer.emptyContext;
    InapplicableMethodException ex = inferDiag ?
            infer.inferenceException : inapplicableMethodException;
    if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
        Object[] args2 = new Object[args.length + 1];
        System.arraycopy(args, 0, args2, 1, args.length);
        args2[0] = inferenceContext.inferenceVars();
        args = args2;
    }
    String key = inferDiag ? diag.inferKey : diag.basicKey;
    throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
}
 
Example #20
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 #21
Source File: Resolve.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
    if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
            argtypes.nonEmpty() &&
            (argtypes.head.hasTag(NONE) ||
            types.isSubtypeUnchecked(inferenceContext.asFree(argtypes.head), site))) {
        return new UnboundMethodReferenceLookupHelper(referenceTree, name,
                site, argtypes, typeargtypes, maxPhase);
    } else {
        return super.unboundLookup(inferenceContext);
    }
}
 
Example #22
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
    if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
            argtypes.nonEmpty() &&
            (argtypes.head.hasTag(NONE) ||
            types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) {
        return new UnboundMethodReferenceLookupHelper(referenceTree, name,
                site, argtypes, typeargtypes, maxPhase);
    } else {
        return super.unboundLookup(inferenceContext);
    }
}
 
Example #23
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
    boolean inferDiag = inferenceContext != infer.emptyContext;
    InapplicableMethodException ex = inferDiag ?
            infer.inferenceException : inapplicableMethodException;
    if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
        Object[] args2 = new Object[args.length + 1];
        System.arraycopy(args, 0, args2, 1, args.length);
        args2[0] = inferenceContext.inferenceVars();
        args = args2;
    }
    String key = inferDiag ? diag.inferKey : diag.basicKey;
    throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
}
 
Example #24
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 #25
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
    if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
            argtypes.nonEmpty() &&
            (argtypes.head.hasTag(NONE) ||
            types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) {
        return new UnboundMethodReferenceLookupHelper(referenceTree, name,
                site, argtypes, typeargtypes, maxPhase);
    } else {
        return super.unboundLookup(inferenceContext);
    }
}
 
Example #26
Source File: DeferredAttr.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Process a deferred attribution node.
 * Invariant: a stuck node cannot be processed.
 */
@SuppressWarnings("fallthrough")
boolean process(final DeferredAttrContext deferredAttrContext) {
    switch (deferredAttrContext.mode) {
        case SPECULATIVE:
            if (deferredStuckPolicy.isStuck()) {
                dt.check(resultInfo, dummyStuckPolicy, new StructuralStuckChecker());
                return true;
            } else {
                Assert.error("Cannot get here");
            }
        case CHECK:
            if (deferredStuckPolicy.isStuck()) {
                //stuck expression - see if we can propagate
                if (deferredAttrContext.parent != emptyDeferredAttrContext &&
                        Type.containsAny(deferredAttrContext.parent.inferenceContext.inferencevars,
                                List.from(deferredStuckPolicy.stuckVars()))) {
                    deferredAttrContext.parent.addDeferredAttrNode(dt,
                            resultInfo.dup(new Check.NestedCheckContext(resultInfo.checkContext) {
                        @Override
                        public InferenceContext inferenceContext() {
                            return deferredAttrContext.parent.inferenceContext;
                        }
                        @Override
                        public DeferredAttrContext deferredAttrContext() {
                            return deferredAttrContext.parent;
                        }
                    }), deferredStuckPolicy);
                    dt.tree.type = Type.stuckType;
                    return true;
                } else {
                    return false;
                }
            } else {
                Assert.check(!deferredAttrContext.insideOverloadPhase(),
                        "attribution shouldn't be happening here");
                ResultInfo instResultInfo =
                        resultInfo.dup(deferredAttrContext.inferenceContext.asInstType(resultInfo.pt));
                dt.check(instResultInfo, dummyStuckPolicy, basicCompleter);
                return true;
            }
        default:
            throw new AssertionError("Bad mode");
    }
}
 
Example #27
Source File: DeferredAttr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void typesInferred(InferenceContext inferenceContext) {
    stuckVars.clear();
}
 
Example #28
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
MethodReferenceCheck(InferenceContext pendingInferenceContext) {
    this.pendingInferenceContext = pendingInferenceContext;
}
 
Example #29
Source File: Check.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public Infer.InferenceContext inferenceContext() {
    return enclosingContext.inferenceContext();
}
 
Example #30
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
Symbol resolveMemberReferenceByArity(Env<AttrContext> env,
                              JCMemberReference referenceTree,
                              Type site,
                              Name name,
                              List<Type> argtypes,
                              InferenceContext inferenceContext) {

    boolean isStaticSelector = TreeInfo.isStaticSelector(referenceTree.expr, names);
    site = types.capture(site);

    ReferenceLookupHelper boundLookupHelper = makeReferenceLookupHelper(
            referenceTree, site, name, argtypes, null, VARARITY);
    //step 1 - bound lookup
    Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup());
    Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym,
            arityMethodCheck, boundLookupHelper);
    if (isStaticSelector &&
        !name.equals(names.init) &&
        !boundSym.isStatic() &&
        boundSym.kind < ERRONEOUS) {
        boundSym = methodNotFound;
    }

    //step 2 - unbound lookup
    Symbol unboundSym = methodNotFound;
    ReferenceLookupHelper unboundLookupHelper = null;
    Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup());
    if (isStaticSelector) {
        unboundLookupHelper = boundLookupHelper.unboundLookup(inferenceContext);
        unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym,
                arityMethodCheck, unboundLookupHelper);
        if (unboundSym.isStatic() &&
            unboundSym.kind < ERRONEOUS) {
            unboundSym = methodNotFound;
        }
    }

    //merge results
    Symbol bestSym = choose(boundSym, unboundSym);
    env.info.pendingResolutionPhase = bestSym == unboundSym ?
            unboundEnv.info.pendingResolutionPhase :
            boundEnv.info.pendingResolutionPhase;

    return bestSym;
}