Java Code Examples for com.sun.tools.javac.comp.Resolve.MethodResolutionContext.Candidate#isApplicable()

The following examples show how to use com.sun.tools.javac.comp.Resolve.MethodResolutionContext.Candidate#isApplicable() . 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 openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected Pair<Symbol, JCDiagnostic> errCandidate() {
    Candidate bestSoFar = null;
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        bestSoFar = c;
    }
    Assert.checkNonNull(bestSoFar);
    return new Pair<Symbol, JCDiagnostic>(bestSoFar.sym, bestSoFar.details);
}
 
Example 2
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private Map<Symbol, JCDiagnostic> mapCandidates() {
    Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        candidates.put(c.sym, c.details);
    }
    return candidates;
}
 
Example 3
Source File: Resolve.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private Map<Symbol, JCDiagnostic> mapCandidates() {
    Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<>();
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        candidates.put(c.sym, c.details);
    }
    return candidates;
}
 
Example 4
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Pair<Symbol, JCDiagnostic> errCandidate() {
    Candidate bestSoFar = null;
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        bestSoFar = c;
    }
    Assert.checkNonNull(bestSoFar);
    return new Pair<Symbol, JCDiagnostic>(bestSoFar.sym, bestSoFar.details);
}
 
Example 5
Source File: Resolve.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
boolean hasAnotherApplicableMethod(MethodResolutionContext resolutionContext,
        Symbol bestSoFar, boolean staticMth) {
    for (Candidate c : resolutionContext.candidates) {
        if (resolutionContext.step != c.step ||
            !c.isApplicable() ||
            c.sym == bestSoFar) {
            continue;
        } else {
            if (c.sym.isStatic() == staticMth) {
                return true;
            }
        }
    }
    return false;
}
 
Example 6
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected Pair<Symbol, JCDiagnostic> errCandidate() {
    Candidate bestSoFar = null;
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        bestSoFar = c;
    }
    Assert.checkNonNull(bestSoFar);
    return new Pair<Symbol, JCDiagnostic>(bestSoFar.sym, bestSoFar.details);
}
 
Example 7
Source File: Resolve.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
boolean hasAnotherApplicableMethod(MethodResolutionContext resolutionContext,
        Symbol bestSoFar, boolean staticMth) {
    for (Candidate c : resolutionContext.candidates) {
        if (resolutionContext.step != c.step ||
            !c.isApplicable() ||
            c.sym == bestSoFar) {
            continue;
        } else {
            if (c.sym.isStatic() == staticMth) {
                return true;
            }
        }
    }
    return false;
}
 
Example 8
Source File: Resolve.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private Map<Symbol, JCDiagnostic> mapCandidates() {
    Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        candidates.put(c.sym, c.details);
    }
    return candidates;
}
 
Example 9
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private Map<Symbol, JCDiagnostic> mapCandidates() {
    Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        candidates.put(c.sym, c.details);
    }
    return candidates;
}
 
Example 10
Source File: Resolve.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
boolean hasAnotherApplicableMethod(MethodResolutionContext resolutionContext,
        Symbol bestSoFar, boolean staticMth) {
    for (Candidate c : resolutionContext.candidates) {
        if (resolutionContext.step != c.step ||
            !c.isApplicable() ||
            c.sym == bestSoFar) {
            continue;
        } else {
            if (c.sym.isStatic() == staticMth) {
                return true;
            }
        }
    }
    return false;
}
 
Example 11
Source File: Resolve.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private Map<Symbol, JCDiagnostic> mapCandidates() {
    Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        candidates.put(c.sym, c.details);
    }
    return candidates;
}
 
Example 12
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private Map<Symbol, JCDiagnostic> mapCandidates() {
    Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        candidates.put(c.sym, c.details);
    }
    return candidates;
}
 
Example 13
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
boolean hasAnotherApplicableMethod(MethodResolutionContext resolutionContext,
        Symbol bestSoFar, boolean staticMth) {
    for (Candidate c : resolutionContext.candidates) {
        if (resolutionContext.step != c.step ||
            !c.isApplicable() ||
            c.sym == bestSoFar) {
            continue;
        } else {
            if (c.sym.isStatic() == staticMth) {
                return true;
            }
        }
    }
    return false;
}
 
Example 14
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private Map<Symbol, JCDiagnostic> mapCandidates() {
    Map<Symbol, JCDiagnostic> candidates = new LinkedHashMap<Symbol, JCDiagnostic>();
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        candidates.put(c.sym, c.details);
    }
    return candidates;
}
 
Example 15
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Pair<Symbol, JCDiagnostic> errCandidate() {
    Candidate bestSoFar = null;
    for (Candidate c : resolveContext.candidates) {
        if (c.isApplicable()) continue;
        bestSoFar = c;
    }
    Assert.checkNonNull(bestSoFar);
    return new Pair<Symbol, JCDiagnostic>(bestSoFar.sym, bestSoFar.details);
}
 
Example 16
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
boolean hasAnotherApplicableMethod(MethodResolutionContext resolutionContext,
        Symbol bestSoFar, boolean staticMth) {
    for (Candidate c : resolutionContext.candidates) {
        if (resolutionContext.step != c.step ||
            !c.isApplicable() ||
            c.sym == bestSoFar) {
            continue;
        } else {
            if (c.sym.isStatic() == staticMth) {
                return true;
            }
        }
    }
    return false;
}
 
Example 17
Source File: Resolve.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site,
        List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
    boolean success = bestSoFar.kind < ERRONEOUS;

    if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
        return;
    } else if (!success && !verboseResolutionMode.contains(VerboseResolutionMode.FAILURE)) {
        return;
    }

    if (bestSoFar.name == names.init &&
            bestSoFar.owner == syms.objectType.tsym &&
            !verboseResolutionMode.contains(VerboseResolutionMode.OBJECT_INIT)) {
        return; //skip diags for Object constructor resolution
    } else if (site == syms.predefClass.type &&
            !verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) {
        return; //skip spurious diags for predef symbols (i.e. operators)
    } else if (currentResolutionContext.internalResolution &&
            !verboseResolutionMode.contains(VerboseResolutionMode.INTERNAL)) {
        return;
    }

    int pos = 0;
    int mostSpecificPos = -1;
    ListBuffer<JCDiagnostic> subDiags = new ListBuffer<>();
    for (Candidate c : currentResolutionContext.candidates) {
        if (currentResolutionContext.step != c.step ||
                (c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.APPLICABLE)) ||
                (!c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.INAPPLICABLE))) {
            continue;
        } else {
            subDiags.append(c.isApplicable() ?
                    getVerboseApplicableCandidateDiag(pos, c.sym, c.mtype) :
                    getVerboseInapplicableCandidateDiag(pos, c.sym, c.details));
            if (c.sym == bestSoFar)
                mostSpecificPos = pos;
            pos++;
        }
    }
    String key = success ? "verbose.resolve.multi" : "verbose.resolve.multi.1";
    List<Type> argtypes2 = Type.map(argtypes,
                deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, bestSoFar, currentResolutionContext.step));
    JCDiagnostic main = diags.note(log.currentSource(), dpos, key, name,
            site.tsym, mostSpecificPos, currentResolutionContext.step,
            methodArguments(argtypes2),
            methodArguments(typeargtypes));
    JCDiagnostic d = new JCDiagnostic.MultilineDiagnostic(main, subDiags.toList());
    log.report(d);
}
 
Example 18
Source File: Resolve.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site,
        List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
    boolean success = bestSoFar.kind < ERRONEOUS;

    if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
        return;
    } else if (!success && !verboseResolutionMode.contains(VerboseResolutionMode.FAILURE)) {
        return;
    }

    if (bestSoFar.name == names.init &&
            bestSoFar.owner == syms.objectType.tsym &&
            !verboseResolutionMode.contains(VerboseResolutionMode.OBJECT_INIT)) {
        return; //skip diags for Object constructor resolution
    } else if (site == syms.predefClass.type &&
            !verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) {
        return; //skip spurious diags for predef symbols (i.e. operators)
    } else if (currentResolutionContext.internalResolution &&
            !verboseResolutionMode.contains(VerboseResolutionMode.INTERNAL)) {
        return;
    }

    int pos = 0;
    int mostSpecificPos = -1;
    ListBuffer<JCDiagnostic> subDiags = new ListBuffer<>();
    for (Candidate c : currentResolutionContext.candidates) {
        if (currentResolutionContext.step != c.step ||
                (c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.APPLICABLE)) ||
                (!c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.INAPPLICABLE))) {
            continue;
        } else {
            subDiags.append(c.isApplicable() ?
                    getVerboseApplicableCandidateDiag(pos, c.sym, c.mtype) :
                    getVerboseInapplicableCandidateDiag(pos, c.sym, c.details));
            if (c.sym == bestSoFar)
                mostSpecificPos = pos;
            pos++;
        }
    }
    String key = success ? "verbose.resolve.multi" : "verbose.resolve.multi.1";
    List<Type> argtypes2 = Type.map(argtypes,
                deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, bestSoFar, currentResolutionContext.step));
    JCDiagnostic main = diags.note(log.currentSource(), dpos, key, name,
            site.tsym, mostSpecificPos, currentResolutionContext.step,
            methodArguments(argtypes2),
            methodArguments(typeargtypes));
    JCDiagnostic d = new JCDiagnostic.MultilineDiagnostic(main, subDiags.toList());
    log.report(d);
}
 
Example 19
Source File: Resolve.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site,
        List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
    boolean success = bestSoFar.kind < ERRONEOUS;

    if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
        return;
    } else if (!success && !verboseResolutionMode.contains(VerboseResolutionMode.FAILURE)) {
        return;
    }

    if (bestSoFar.name == names.init &&
            bestSoFar.owner == syms.objectType.tsym &&
            !verboseResolutionMode.contains(VerboseResolutionMode.OBJECT_INIT)) {
        return; //skip diags for Object constructor resolution
    } else if (site == syms.predefClass.type &&
            !verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) {
        return; //skip spurious diags for predef symbols (i.e. operators)
    } else if (currentResolutionContext.internalResolution &&
            !verboseResolutionMode.contains(VerboseResolutionMode.INTERNAL)) {
        return;
    }

    int pos = 0;
    int mostSpecificPos = -1;
    ListBuffer<JCDiagnostic> subDiags = new ListBuffer<>();
    for (Candidate c : currentResolutionContext.candidates) {
        if (currentResolutionContext.step != c.step ||
                (c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.APPLICABLE)) ||
                (!c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.INAPPLICABLE))) {
            continue;
        } else {
            subDiags.append(c.isApplicable() ?
                    getVerboseApplicableCandidateDiag(pos, c.sym, c.mtype) :
                    getVerboseInapplicableCandidateDiag(pos, c.sym, c.details));
            if (c.sym == bestSoFar)
                mostSpecificPos = pos;
            pos++;
        }
    }
    String key = success ? "verbose.resolve.multi" : "verbose.resolve.multi.1";
    List<Type> argtypes2 = Type.map(argtypes,
                deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, bestSoFar, currentResolutionContext.step));
    JCDiagnostic main = diags.note(log.currentSource(), dpos, key, name,
            site.tsym, mostSpecificPos, currentResolutionContext.step,
            methodArguments(argtypes2),
            methodArguments(typeargtypes));
    JCDiagnostic d = new JCDiagnostic.MultilineDiagnostic(main, subDiags.toList());
    log.report(d);
}
 
Example 20
Source File: Resolve.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site,
        List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
    boolean success = !bestSoFar.kind.isResolutionError();

    if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
        return;
    } else if (!success && !verboseResolutionMode.contains(VerboseResolutionMode.FAILURE)) {
        return;
    }

    if (bestSoFar.name == names.init &&
            bestSoFar.owner == syms.objectType.tsym &&
            !verboseResolutionMode.contains(VerboseResolutionMode.OBJECT_INIT)) {
        return; //skip diags for Object constructor resolution
    } else if (site == syms.predefClass.type &&
            !verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) {
        return; //skip spurious diags for predef symbols (i.e. operators)
    } else if (currentResolutionContext.internalResolution &&
            !verboseResolutionMode.contains(VerboseResolutionMode.INTERNAL)) {
        return;
    }

    int pos = 0;
    int mostSpecificPos = -1;
    ListBuffer<JCDiagnostic> subDiags = new ListBuffer<>();
    for (Candidate c : currentResolutionContext.candidates) {
        if (currentResolutionContext.step != c.step ||
                (c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.APPLICABLE)) ||
                (!c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.INAPPLICABLE))) {
            continue;
        } else {
            subDiags.append(c.isApplicable() ?
                    getVerboseApplicableCandidateDiag(pos, c.sym, c.mtype) :
                    getVerboseInapplicableCandidateDiag(pos, c.sym, c.details));
            if (c.sym == bestSoFar)
                mostSpecificPos = pos;
            pos++;
        }
    }
    String key = success ? "verbose.resolve.multi" : "verbose.resolve.multi.1";
    List<Type> argtypes2 = argtypes.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, bestSoFar, currentResolutionContext.step));
    JCDiagnostic main = diags.note(log.currentSource(), dpos, key, name,
            site.tsym, mostSpecificPos, currentResolutionContext.step,
            methodArguments(argtypes2),
            methodArguments(typeargtypes));
    JCDiagnostic d = new JCDiagnostic.MultilineDiagnostic(main, subDiags.toList());
    log.report(d);
}