tryResolveCall¶
context(session: KaSession)
fun KtResolvableCall.tryResolveCall(): KaCallResolutionAttempt?
Attempts to resolve the call for the given KtResolvableCall.
Usage Example:¶
context(session: KaSession)
fun findResolutionDiagnostic(expression: KtCallExpression): KaDiagnostic? {
val attempt = expression.tryResolveCall() ?: return null
return attempt.errors.firstOrNull()?.diagnostic
}
Returns a KaCallResolutionAttempt, or null when there is no call to resolve: the element is not call-shaped, or its reference resolves to something non-callable, such as a qualifier, an import, or a type. Broken code can end up here as well.
A non-null result describes the outcome of an actual resolution. Check it with errors or isSuccessful rather than with a type check, which only covers simple attempts. A reported error may carry an empty candidateCalls list.
See References and Calls for a top-level overview.
See also¶
context(session: KaSession)
fun KtForExpression.tryResolveCall(): KaForLoopCallResolutionAttempt?
Attempts to resolve the given KtForExpression to a KaForLoopCallResolutionAttempt containing the individual resolution results for each desugared operator call (iterator, hasNext, next).
This is a specialized counterpart of KtResolvableCall.tryResolveCall focused specifically on for loops.
See also¶
context(session: KaSession)
fun KtPropertyDelegate.tryResolveCall(): KaDelegatedPropertyCallResolutionAttempt?
Attempts to resolve the given KtPropertyDelegate to a KaDelegatedPropertyCallResolutionAttempt containing the individual resolution results for each desugared operator call (getValue, setValue, provideDelegate).
This is a specialized counterpart of KtResolvableCall.tryResolveCall focused specifically on delegated properties.