Skip to content

KaImplicitReceiverValue

An implicit receiver value.

Example

class A {
  val i: Int = 1
  fun test() {
    i    // The implicit receiver of type `A` is bound to the `KaNamedClassSymbol` of class `A`.
  }
}

fun String.test() {
  length // The implicit receiver of type `String` is bound to the `KaReceiverParameterSymbol` for the extension receiver of `test`.
}

Properties

symbol

abstract val symbol: KaSymbol

The symbol which represents the implicit receiver.

token

abstract val token: KaLifetimeToken

The KaLifetimeToken which determines the lifetime of the lifetime owner.

type

abstract val type: KaType

The inferred KaType of the receiver. This is a smart-casted type in the case of a smart cast on the receiver.

Functions

assertIsValidAndAccessible

isValid

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.