KaCompoundArrayAccessCall¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaCompoundArrayAccessCall : KaMultiCall, KaCall, KaCompoundAccessCall
A compound access using the array access convention, involving calls to both the get() and set() functions. For example, a[1] += "foo" is such an array compound access.
Example¶
fun test(m: MutableMap<String, String>) {
m["a"] += "b"
// indexArguments: ["a"]
// getPartiallyAppliedSymbol: {
// symbol: MutableMap.get()
// dispatchReceiver: `m`
// extensionReceiver: null
// }
// setPartiallyAppliedSymbol: {
// symbol: MutableMap.set()
// dispatchReceiver: `m`
// extensionReceiver: null
// }
// accessType: OpAssign {
// kind: PLUS
// operand: "b"
// operationSymbol: String?.plus()
// }
}
Such a call always involves both calls to the get and set functions. With the example above, a call to String?.plus is sandwiched between a get and a set call to compute the new value passed to set.
<op>Assign function calls¶
Simple access using the array access convention is not captured by this class. If the collection has an <op>Assign operator, the call is represented as a simple KaFunctionCall.
For example, assuming ThrowingMap throws in case of an absent key instead of returning null:
The above call is represented as a simple KaFunctionCall to MutableList.plusAssign, with the dispatch receiver referencing the expression m["a"], which is again a simple KaFunctionCall to ThrowingMap.get.
Properties¶
calls¶
abstract val calls: List<KaSimpleCall<*, *>>
The non-empty list of KaSimpleCalls that were discovered during resolution of KtResolvableCall
calls¶
val KaCallInfo.calls: List<KaCall>
The list of KaCalls associated with the KaCallInfo. The list contains a single KaCall in case of a successful call, but may contain multiple candidates in case of an error call.
The flattened list of resolved calls.
-
KaSimpleCallResolutionSuccess: the resolvedcallas a single-element list. -
KaMultiCallResolutionAttempt: the assembledcallif all sub-calls succeeded, or the combined calls from individualsimpleAttemptsotherwise.
val KaSimpleOrMultiCall.calls: List<KaSimpleCall<*, *>>
The flattened list of KaSimpleCalls.
-
If
thisis an instance ofKaSimpleCall, the list will contain onlythiscall -
If
thisis an instance ofKaMultiCall, the list will containKaMultiCall.calls
compoundOperation¶
abstract val compoundOperation: KaCompoundOperation
The corresponding compound operation.
constructor¶
this call as a call to a constructor, or null if it is not a constructor call.
Example
Both the Foo() call and the @Anno annotation entry are constructor calls, so constructor returns the call itself.
See also
function¶
val KaSimpleOrMultiCall.function: KaFunctionCall<*>?
this call as a KaFunctionCall, or null if it is not a call to a function.
Example
For function(), function is the call to function. For int, which is a KaVariableAccessCall, function is null.
See also
getterCall¶
abstract val getterCall: KaFunctionCall<KaNamedFunctionSymbol>
A call of the get function that's invoked when reading values corresponding to the given indexArguments.
indexArguments¶
abstract val indexArguments: List<KtExpression>
The arguments representing the indices in the index access operator call.
Example
operationCall¶
open val operationCall: KaFunctionCall<KaNamedFunctionSymbol>
Represents a call of the operator
setterCall¶
abstract val setterCall: KaFunctionCall<KaNamedFunctionSymbol>
A call of the set function that's invoked when writing values corresponding to the given indexArguments and the computed value from the operation
simple¶
val KaSimpleOrMultiCall.simple: KaSimpleCall<*, *>?
this call as a KaSimpleCall, or null if it is a KaMultiCall.
Example
For int = 2, simple is the write access to int. For int++, which is a KaMultiCall, simple is null.
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.
variable¶
this call as a KaVariableAccessCall, or null if it is not an access to a variable.
Example
For int, variable is the read access to int. For function(), which is a KaFunctionCall, variable is null.
See also
Functions¶
assertIsValidAndAccessible¶
inline fun KaLifetimeOwner.assertIsValidAndAccessible()
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.