KaSimpleSymbolResolutionError¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaSimpleSymbolResolutionError : KaSimpleSymbolResolutionAttempt
Represents an error that occurred during the resolution of a KtResolvable
A KaCompoundSymbolResolutionError is not an instance of this type, so a type check against this type is not a complete failure check — use errors or isSuccessful instead.
Example¶
bar() will be resolved to KaSimpleSymbolResolutionError with INVISIBLE_REFERENCE diagnostic and the bar symbol candidate
Properties¶
candidateSymbols¶
abstract val candidateSymbols: List<KaSymbol>
Represents a collection of candidate symbols for a resolution attempt.
Code example:
here m.property is resolved into KaSimpleSymbolResolutionError because it is invisible from the call site, but the compiler produces INVISIBLE_REFERENCE diagnostic with property candidate
Note: the collection can be empty
diagnostic¶
abstract val diagnostic: KaDiagnostic
Defines a reason why this attempt is unsuccessful
errors¶
The list of errors that occurred during the resolution.
-
KaSimpleCallResolutionSuccess: an empty list. -
KaSimpleCallResolutionError:thiserror as a single-element list. -
KaMultiCallResolutionAttempt: the errors among the individualsub-attempts. A multi-call attempt fails as soon as any of its sub-calls fails, so the list is empty if and only if the assembledcallis notnull.
The list is empty if and only if the resolution succeeded. So, unlike a this is KaSimpleCallResolutionError check, which only covers simple attempts, this property detects failures of every attempt kind.
See also
The list of errors that occurred during the resolution.
-
KaSimpleSymbolResolutionSuccess: an empty list. -
KaSimpleSymbolResolutionError:thiserror as a single-element list. -
KaCompoundSymbolResolutionError: the errors among the individualsub-attempts, which always contain at least one.
The list is empty if and only if the resolution succeeded. So, unlike a this is KaSimpleSymbolResolutionError check, which only covers simple attempts, this property detects failures of every attempt kind.
See also
isSuccessful¶
Whether the resolution succeeded.
true if and only if successful is not null, and equivalently if and only if errors is empty.
Unlike a this is KaSimpleCallResolutionSuccess check, which only covers simple attempts, this property also accounts for KaMultiCallResolutionAttempt, which fails as soon as any of its sub-calls fails.
See also
Whether the resolution succeeded.
true if and only if errors is empty. A KaCompoundSymbolResolutionError is always a failure, even when some of its sub-attempts succeeded.
See also
simpleAttempts¶
The flattened list of simple resolution attempts.
-
KaSimpleCallResolutionAttempt:thisattempt as a single-element list. -
KaMultiCallResolutionAttempt: the individualsub-attempts.
The list is never empty.
The flattened list of simple resolution attempts.
-
KaSimpleSymbolResolutionAttempt:thisattempt as a single-element list. -
KaCompoundSymbolResolutionError: the individualsub-attempts.
The list is never empty.
successfulSymbols¶
The resolved symbols if the resolution succeeded, or an empty list if it failed.
A successful resolution always has at least one symbol, so an empty list always means a failure.
See also
symbols¶
The flattened list of KaSymbols for the resolved calls.
-
If
thisis an instance ofKaSimpleCall, the list will contain only theKaSimpleCall.signature's symbol -
If
thisis an instance ofKaMultiCall, the list will contain symbols from allKaMultiCall.calls
A list of KaSymbol.
-
If
thisis an instance ofKaSimpleSymbolResolutionSuccess, the list will containKaSimpleSymbolResolutionSuccess.symbols. -
If
thisis an instance ofKaSimpleSymbolResolutionError, the list will containKaSimpleSymbolResolutionError.candidateSymbols. -
If
thisis an instance ofKaCompoundSymbolResolutionError, the list will contain the combined symbols from all attempts.
See also
token¶
abstract val token: KaLifetimeToken
The KaLifetimeToken which determines the lifetime of the lifetime owner.
Functions¶
assertIsValidAndAccessible¶
inline fun KaLifetimeOwner.assertIsValidAndAccessible()
fold¶
inline fun <T> KaCallResolutionAttempt.fold(onSuccess: (KaSimpleOrMultiCall) -> T, onFailure: (List<KaSimpleCallResolutionError>) -> T): T
Folds over a KaCallResolutionAttempt depending on whether the resolution succeeded.
-
KaSimpleCallResolutionSuccess: invokesonSuccesswith the resolvedcall. -
KaSimpleCallResolutionError: invokesonFailurewith the error wrapped in a single-element list. -
KaMultiCallResolutionAttempt: if all sub-calls succeeded, invokesonSuccesswith the assembledcall; otherwise invokesonFailurewith theerrorsof the failed sub-calls. The successful sub-calls are not passed toonFailure; usesimpleAttemptsto reach them.
inline fun <T> KaSymbolResolutionAttempt.fold(onSuccess: (List<KaSymbol>) -> T, onFailure: (List<KaSimpleSymbolResolutionError>) -> T): T
Folds over a KaSymbolResolutionAttempt depending on whether the resolution succeeded.
-
KaSimpleSymbolResolutionSuccess: invokesonSuccesswith the resolvedsymbols. -
KaSimpleSymbolResolutionError: invokesonFailurewith the error wrapped in a single-element list. -
KaCompoundSymbolResolutionError: invokesonFailurewith theerrorsof the failed sub-calls. The successful sub-call, if any, is not passed toonFailure; usesimpleAttemptsto reach it.
isValid¶
fun KaLifetimeOwner.isValid(): Boolean
Whether the lifetime owner is still valid, i.e. we are still in the scope of the lifetime owner's regular lifetime.
withValidityAssertion¶
inline fun <R> KaLifetimeOwner.withValidityAssertion(action: () -> R): R
Executes action only if the KaLifetimeOwner is still valid and accessible. Otherwise, throws a validity exception based on the concrete violation.