Search in sources :

Example 1 with Candidate

use of org.eclipse.ceylon.langtools.tools.javac.comp.Resolve.MethodResolutionContext.Candidate in project ceylon by eclipse.

the class Resolve method reportVerboseResolutionDiagnostic.

void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site, List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
    boolean success = bestSoFar.kind < Kinds.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)) {
        // skip diags for Object constructor resolution
        return;
    } else if (site == syms.predefClass.type && !verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) {
        // skip spurious diags for predef symbols (i.e. operators)
        return;
    } 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);
}
Also used : Candidate(org.eclipse.ceylon.langtools.tools.javac.comp.Resolve.MethodResolutionContext.Candidate) Type(org.eclipse.ceylon.langtools.tools.javac.code.Type) DeferredType(org.eclipse.ceylon.langtools.tools.javac.comp.DeferredAttr.DeferredType) DiagnosticType(org.eclipse.ceylon.langtools.tools.javac.util.JCDiagnostic.DiagnosticType) LocalizedString(org.eclipse.ceylon.langtools.tools.javac.api.Formattable.LocalizedString)

Aggregations

LocalizedString (org.eclipse.ceylon.langtools.tools.javac.api.Formattable.LocalizedString)1 Type (org.eclipse.ceylon.langtools.tools.javac.code.Type)1 DeferredType (org.eclipse.ceylon.langtools.tools.javac.comp.DeferredAttr.DeferredType)1 Candidate (org.eclipse.ceylon.langtools.tools.javac.comp.Resolve.MethodResolutionContext.Candidate)1 DiagnosticType (org.eclipse.ceylon.langtools.tools.javac.util.JCDiagnostic.DiagnosticType)1