Skip to content

KaTypeCreator

@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaTypeCreator : KaSessionComponent

Inheritors

Properties

token

abstract val token: KaLifetimeToken

The KaLifetimeToken which determines the lifetime of the lifetime owner.

Functions

assertIsValidAndAccessible

buildArrayType

abstract fun buildArrayType(elementType: KaType, init: KaArrayTypeBuilder.() -> Unit = {}): KaType

Builds a boxed / primitive (depending on the init block) array type from the given elementType.

buildClassType

abstract fun buildClassType(classId: ClassId, init: KaClassTypeBuilder.() -> Unit = {}): KaType

Builds a class type with the given class ID.

A generic class type can be built by providing type arguments using the init block. The caller is supposed to provide the correct number of type arguments for the class.

For Kotlin built-in types, consider using the overload that accepts a KaClassLikeSymbol instead: buildClassType(builtinTypes.string).

Example

buildClassType(ClassId.fromString("kotlin/collections/List")) {
    argument(buildClassType(ClassId.fromString("kotlin/String")))
}
abstract fun buildClassType(symbol: KaClassLikeSymbol, init: KaClassTypeBuilder.() -> Unit = {}): KaType

Builds a class type with the given class symbol.

A generic class type can be built by providing type arguments using the init block. The caller is supposed to provide the correct number of type arguments for the class.

Example

buildClassType(builtinTypes.string)

buildStarTypeProjection

buildTypeParameterType

Builds a KaTypeParameterType with the given type parameter symbol.

buildVarargArrayType

abstract fun buildVarargArrayType(elementType: KaType): KaType

Builds the underlying array type of vararg function parameter with the given elementType.

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.