resolveSuccessfulCall¶
context(session: KaSession)
fun KtResolvableCall.resolveSuccessfulCall(): KaSimpleOrMultiCall?
Resolves the call for the given KtResolvableCall.
Usage Example:¶
context(session: KaSession)
fun resolveSymbol(expression: KtCallExpression): KaSymbol? {
return expression.resolveSuccessfulCall()?.simple?.symbol
}
Returns the resolved KaSimpleOrMultiCall on success; otherwise, null
See also¶
context(session: KaSession)
fun KtAnnotationEntry.resolveSuccessfulCall(): KaAnnotationCall?
Resolves the given KtAnnotationEntry to an annotation constructor call.
Example¶
Returns the corresponding KaAnnotationCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on annotation entries. Use collectCallCandidates to inspect all candidates considered during overload resolution
See also¶
context(session: KaSession)
fun KtSuperTypeCallEntry.resolveSuccessfulCall(): KaFunctionCall<KaConstructorSymbol>?
Resolves the given KtSuperTypeCallEntry to a constructor call of the referenced supertype.
Example¶
Returns the corresponding KaFunctionCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on supertype constructor calls
See also¶
context(session: KaSession)
fun KtConstructorDelegationCall.resolveSuccessfulCall(): KaDelegatedConstructorCall?
Resolves the given KtConstructorDelegationCall to a delegated constructor call.
Example¶
open class Base(val i: Int)
class Derived : Base {
constructor() : this(0)
// ^^^^^^^
constructor(x: Int) : super(x)
// ^^^^^^^^
}
Returns the corresponding KaDelegatedConstructorCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on constructor delegation calls
See also¶
context(session: KaSession)
fun KtConstructorDelegationReferenceExpression.resolveSuccessfulCall(): KaDelegatedConstructorCall?
Resolves the given KtConstructorDelegationReferenceExpression to a delegated constructor call.
Example¶
open class Base(val i: Int)
class Derived : Base {
constructor() : this(0)
// ^^^^
constructor(x: Int) : super(x)
// ^^^^^
}
Returns the corresponding KaDelegatedConstructorCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on constructor delegation calls
See also¶
context(session: KaSession)
fun KtCallElement.resolveSuccessfulCall(): KaFunctionCall<*>?
Resolves the given KtCallElement to a function call.
Example¶
Returns the corresponding KaSimpleCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on call elements
See also¶
context(session: KaSession)
fun KtCallableReferenceExpression.resolveSuccessfulCall(): KaCallableReferenceCall<*, *>?
Resolves the given KtCallableReferenceExpression to a callable member call.
Example¶
Returns the corresponding KaCallableReferenceCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on callable reference expressions
See also¶
context(session: KaSession)
fun KtArrayAccessExpression.resolveSuccessfulCall(): KaFunctionCall<KaNamedFunctionSymbol>?
Resolves the given KtArrayAccessExpression to a simple function call representing get/set operator invocation.
Example¶
class A {
operator fun get(i: Int): Int = i
operator fun set(i: Int, value: Int) {}
}
fun test(a: A) {
a[0]
// ^^^^ resolves to `get`
a[0] = 1
// ^^^^ resolves to `set`
}
Returns the corresponding KaSimpleFunctionCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on array access operations.
Note: the get call is prefered in the case of a compound assignent
See also¶
context(session: KaSession)
fun KtCollectionLiteralExpression.resolveSuccessfulCall(): KaFunctionCall<KaNamedFunctionSymbol>?
Resolves the given KtCollectionLiteralExpression to a simple function call representing the corresponding array factory invocation.
Example¶
annotation class Anno(val arr: IntArray)
@Anno([1, 2, 3])
// ^^^^^^^^^ resolves to a call of `intArrayOf`
fun use() {}
Returns the corresponding KaSimpleFunctionCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on collection literal expressions
See also¶
context(session: KaSession)
fun KtEnumEntrySuperclassReferenceExpression.resolveSuccessfulCall(): KaDelegatedConstructorCall?
Resolves the given KtEnumEntrySuperclassReferenceExpression to a delegated constructor call.
Example¶
enum class EnumWithConstructor(val x: Int) {
Entry(1)
// ^ resolves to the constructor of `EnumWithConstructor`
}
Returns the corresponding KaDelegatedConstructorCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on enum entry superclass constructor calls
See also¶
context(session: KaSession)
fun KtWhenConditionInRange.resolveSuccessfulCall(): KaFunctionCall<KaNamedFunctionSymbol>?
Resolves the given KtWhenConditionInRange to a simple function call representing the corresponding contains operator invocation used by the in/!in branch condition.
Example¶
fun test(x: Int) {
when (x) {
in 1..10 -> {}
// ^^^^^^^^ resolves to a call of `IntRange.contains`
!in setOf(1, 2, 3) -> {}
// ^^^^^^^^^^^^^^^^^^ resolves to a call of `Set<Int>.contains`
}
}
Returns the corresponding KaSimpleFunctionCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on in/!in range conditions inside when entries
See also¶
context(session: KaSession)
fun KtDestructuringDeclarationEntry.resolveSuccessfulCall(): KaSimpleCall<*, *>?
Resolves the given KtDestructuringDeclarationEntry to a call representing the componentN invocation (for positional destructuring) or the property access (for name-based destructuring).
Example¶
data class Point(val x: Int, val y: Int)
fun test(p: Point) {
val (x, y) = p
// ^ resolves to a call of `component1`
// ^ resolves to a call of `component2`
}
Returns the corresponding KaSimpleCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on destructuring declaration entries
See also¶
context(session: KaSession)
fun KtQualifiedExpression.resolveSuccessfulCall(): KaSimpleCall<*, *>?
Resolves the given KtQualifiedExpression to a call representing the member or extension access.
Example¶
Calling resolveSuccessfulCall() on the KtQualifiedExpression (str.length) returns the corresponding KaSimpleCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on qualified expressions
See also¶
context(session: KaSession)
fun KtForExpression.resolveSuccessfulCall(): KaForLoopCall?
Resolves the given KtForExpression to a KaForLoopCall representing the desugared for loop.
A for loop desugars into three operator calls:
-
iterator()on the loop range expression -
hasNext()on the iterator -
next()on the iterator
Example¶
Calling resolveSuccessfulCall() on the KtForExpression returns a KaForLoopCall containing the three desugared operator calls if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on for loops
See also¶
context(session: KaSession)
fun KtPropertyDelegate.resolveSuccessfulCall(): KaDelegatedPropertyCall?
Resolves the given KtPropertyDelegate to a KaDelegatedPropertyCall representing the desugared delegated property.
A delegated property desugars into up to three operator calls:
-
getValue()on the delegate object -
setValue()on the delegate object (only forvarproperties) -
provideDelegate()on the delegate expression (if applicable)
Example¶
Calling resolveSuccessfulCall() on the KtPropertyDelegate returns a KaDelegatedPropertyCall containing the desugared operator calls if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on delegated properties
See also¶
context(session: KaSession)
fun KtConstructorCalleeExpression.resolveSuccessfulCall(): KaFunctionCall<KaConstructorSymbol>?
Resolves the given KtConstructorCalleeExpression to a constructor call.
Example¶
Returns the corresponding KaFunctionCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on constructor callee expressions
See also¶
context(session: KaSession)
fun KtNameReferenceExpression.resolveSuccessfulCall(): KaSimpleCall<*, *>?
Resolves the given KtNameReferenceExpression to a call representing the referenced declaration.
Example¶
Calling resolveSuccessfulCall() on the KtNameReferenceExpression (foo) returns the corresponding KaSimpleCall if resolution succeeds; otherwise, it returns null (e.g., when unresolved or ambiguous).
This is a specialized counterpart of KtResolvableCall.resolveSuccessfulCall focused specifically on name reference expressions