Skip to content

resolveSuccessfulCall

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

Resolves the given KtAnnotationEntry to an annotation constructor call.

Example

annotation class Anno(val x: Int)

@Anno(42)
fun foo() {}

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

Resolves the given KtSuperTypeCallEntry to a constructor call of the referenced supertype.

Example

open class Base(i: Int)

class Derived : Base(1)
//              ^^^^^^^

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

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

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

Resolves the given KtCallElement to a function call.

Example

fun foo(x: Int) {}

fun test() {
    foo(42)
//  ^^^^^^^
}

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

Resolves the given KtCallableReferenceExpression to a callable member call.

Example

class A { fun foo() {} }

val ref = A::foo
//        ^^^^^^

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

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

fun test(m: MyMap<String, Int>) {
    m["a"] += 1
//  ^^^^^^
}

See also

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

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

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

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

Resolves the given KtQualifiedExpression to a call representing the member or extension access.

Example

val len = str.length
//        ^________^

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

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

for (item in list) {
    println(item)
}

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

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 for var properties)

  • provideDelegate() on the delegate expression (if applicable)

Example

val name: String by lazy { "John" }
//               ^________________^

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

Resolves the given KtConstructorCalleeExpression to a constructor call.

Example

open class Base(i: Int)

class Derived : Base(1)
//              ^^^^

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

Resolves the given KtNameReferenceExpression to a call representing the referenced declaration.

Example

fun foo() {}

val x = foo
//      ^^^

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

See also