Skip to content

org.jetbrains.kotlin.analysis.api.types

Types

KaBuiltinFunctionTypeFamilies

Provides access to the four built-in function type families.

KaBuiltinTypes

KaType instances for built-in types.

KaCapturedType

KaClassErrorType

KaClassErrorType represents a class type that failed to resolve correctly.

KaClassType

sealed class KaClassType : KaType

KaClassType represents a generic class type or a function type.

KaClassTypeQualifier

A type qualifier is a segment in a multi-segment class type application.

KaDefinitelyNotNullType

KaDefinitelyNotNullType represents a definitely not-null type, such as T & Any for a type parameter T.

KaDynamicType

KaDynamicType represents a dynamic type, which is used to support interoperability with dynamically typed libraries, platforms, or languages.

KaErrorType

KaErrorType represents a type that failed to resolve correctly.

KaFlexibleType

KaFlexibleType represents a flexible type (or a so-called platform type), a range of types from the lowerBound to the upperBound (both inclusive).

KaFunctionType

KaFunctionType represents a Kotlin function type, such as (String) -> Int or suspend () -> List<Any>.

KaFunctionTypeFamily

Describes a family of numbered function types such as Function0, Function1, ..., FunctionN.

KaFunctionValueParameter

Represents a function value parameter

KaIntersectionType

KaIntersectionType represents an intersection type, such as A & B. Intersection types cannot be denoted in Kotlin code, but can result from some compiler operations, such as smart casts.

KaResolvedClassTypeQualifier

KaStandardTypeClassIds

The object contains ClassIds of well known Kotlin types.

KaStarTypeProjection

Represents a star projection (*) used in type arguments. It indicates that the specific type argument is not important or unknown.

KaSubstitutor

A type substitutor which performs a substitution of type parameters inside a type to another type. The substitution can usually be represented as a map from type parameters to their corresponding substitution types.

KaSubstitutorBuilder

KaSubtypingErrorTypePolicy

KaSubtypingErrorTypePolicy determines the treatment of error types in type equality and subtyping checks.

KaType

KaType represents a concrete Kotlin type, such as Int, Foo for a class Foo, or Bar<String> for a class Bar<T>. It provides information about type structure, nullability, and annotations.

KaTypeArgumentWithVariance

Represents a type argument with an explicit type and variance.

KaTypeMappingMode

KaTypeMappingMode determines how a Kotlin type is mapped to a Java type when calling KaType.asPsiType.

KaTypeParameterType

KaTypeParameterType represents a type parameter type, such as T in the declaration class Box<T>(val element: T).

KaTypePointer

KaTypePointer allows to point to a KaType and later retrieve it in another KaSession. A pointer is necessary because KaTypes cannot be shared past the boundaries of the KaSession they were created in, as they are valid only there.

KaTypeProjection

sealed interface KaTypeProjection : KaLifetimeOwner

KaTypeProjection represents a type argument used in the context of a class or function type. It provides information about the type and its variance.

KaUnificationSubstitutorPolicy

KaUnificationSubstitutorPolicy determines the way unification KaSubstitutors are created in createSubtypingUnificationSubstitutor. Note that the policy only affects the construction when at least one of the involved types is generic, i.e., depends on a type parameter.

KaUnresolvedClassTypeQualifier

KaUsualClassType

KaUsualClassType represents a generic class type, such as String or List<Int>.

Properties

builtinFunctionTypeFamilies

Provides access to the built-in function type families.

builtinTypes

context(session: KaSession)
val builtinTypes: KaBuiltinTypes

KaType instances for built-in types.

commonSupertype

context(session: KaSession)
val Array<KaType>.commonSupertype: KaType

The common supertype of the given KaTypes.

context(session: KaSession)
val Iterable<KaType>.commonSupertype: KaType

The common supertype of the given KaTypes.

defaultType

The representation of this in terms of KaType.

defaultTypeWithStarProjections

The representation of this in terms of KaType.

emptySubstitutor

Creates KaSubstitutor.Empty, i.e., a substitutor without any mappings.

receiverType

Resolves the given KtDoubleColonExpression to the KaType of its receiver.

type

context(session: KaSession)
val KtTypeReference.type: KaType

Resolves the given KtTypeReference to its corresponding KaType.

varargArrayType

The array type that represents the list of arguments passed to this parameter if this is a vararg parameter.

Functions

buildSubstitutor

context(session: KaSession)
fun buildSubstitutor(build: KaSubstitutorBuilder.() -> Unit): KaSubstitutor

Builds a new KaSubstitutor from substitutions specified inside build.

createInheritanceTypeSubstitutor

context(session: KaSession)
fun createInheritanceTypeSubstitutor(subClass: KaClassSymbol, superClass: KaClassSymbol): KaSubstitutor?

Creates a KaSubstitutor based on the inheritance relationship between subClass and superClass. subClass must inherit from superClass and there may not be any error types in the inheritance path. Otherwise, null is returned.

createSubstitutor

Creates a KaSubstitutor based on the given mappings.

createSubtypingUnificationSubstitutor

context(session: KaSession)
fun createSubtypingUnificationSubstitutor(leftTypesToRightTypes: List<Pair<KaType, KaType>>, isFreeTypeParameter: (KaTypeParameterSymbol) -> Boolean): KaSubstitutor?

Creates a KaSubstitutor which assigns type arguments such that, for each pair in leftTypesToRightTypes, the substituted left type is a subtype of the substituted right type. Returns null if such an assignment is not possible.

context(session: KaSession)
fun createSubtypingUnificationSubstitutor(leftTypesToRightTypes: List<Pair<KaType, KaType>>, constructionPolicy: KaUnificationSubstitutorPolicy): KaSubstitutor?

Creates a KaSubstitutor which assigns type arguments such that, for each pair in leftTypesToRightTypes, the substituted left type is a subtype of the substituted right type. Returns null if such an assignment is not possible.

context(session: KaSession)
fun createSubtypingUnificationSubstitutor(
    leftType: KaType, 
    rightType: KaType, 
    constructionPolicy: KaUnificationSubstitutorPolicy
): KaSubstitutor?

Creates a KaSubstitutor which assigns type arguments such that the substituted leftType is a subtype of the substituted rightType. Returns null if such an assignment is not possible.