KaSymbolResolutionAttempt
KaSymbolResolutionAttempt is the rich result type of tryResolveSymbols(). Unlike the plain resolveSymbol()/resolveSymbols() — which collapse failures to null — an attempt always carries everything the compiler considered: either the resolved symbols, or a diagnostic together with candidate symbols, or a mix of both for compound calls.
This page documents the sealed hierarchy and the helper extensions. For the high-level "how do I use this?" view, see Resolving Symbols.
Hierarchy
Members
KaSymbolResolutionAttempt
The sealed root. Two branches: KaSingleSymbolResolutionAttempt and KaCompoundSymbolResolutionError.
KaSingleSymbolResolutionAttempt
A resolution attempt for a single conceptual target. One of:
KaSymbolResolutionSuccessResolution succeeded. Exposes
symbols: List<KaSymbol>— one entry for unambiguous resolution, several for ambiguity. The list is always non-empty.KaSymbolResolutionErrorResolution failed. Exposes
diagnostic: KaDiagnosticdescribing the reason andcandidateSymbols: List<KaSymbol>— the symbols the compiler considered before giving up (e.g. anINVISIBLE_REFERENCEerror still names the invisible declaration as a candidate). The list may be empty.
KaCompoundSymbolResolutionError
Returned only when a compound resolution produced a mix of successful and failed sub-attempts (or all sub-attempts failed). Exposes attempts: List<KaSingleSymbolResolutionAttempt> — at most one KaSymbolResolutionSuccess (merging symbols from all successful sub-calls) and at least one KaSymbolResolutionError, totaling at least two entries. When every sub-attempt succeeds, the result is KaSymbolResolutionSuccess instead.
Helper extensions
The sealed hierarchy is exhaustive, but most callers do not need to pattern-match on it. Two extension properties cover the common cases:
val KaSymbolResolutionAttempt.symbols: List<KaSymbol>Every symbol the compiler considered, regardless of success or failure. On success returns the resolved symbols; on error returns the candidate symbols; on a compound error returns the combined symbols from all sub-attempts. Use this for "best effort" navigation that wants to highlight anything reachable.
val KaSymbolResolutionAttempt.successfulSymbols: List<KaSymbol>The resolved symbols if resolution succeeded; empty otherwise. Use this when you want to silently drop failed resolutions.
For full control, use the fold extension:
onSuccess is invoked once with the resolved symbols when all sub-attempts succeeded; onFailure is invoked with the list of individual KaSingleSymbolResolutionAttempts otherwise — including the single error case (a one-element list) and the compound mixed case.