org.jetbrains.kotlin.analysis.api.types¶
Types¶
KaBuiltinFunctionTypeFamilies¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaBuiltinFunctionTypeFamilies
Provides access to the four built-in function type families.
KaBuiltinTypes¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaBuiltinTypes : KaLifetimeOwner
KaType instances for built-in types.
KaCapturedType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaCapturedType : KaType
KaCapturedType represents a captured type.
KaClassErrorType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaClassErrorType : KaErrorType
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¶
sealed interface KaClassTypeQualifier : KaLifetimeOwner
A type qualifier is a segment in a multi-segment class type application.
KaDefinitelyNotNullType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaDefinitelyNotNullType : KaType
KaDefinitelyNotNullType represents a definitely not-null type, such as T & Any for a type parameter T.
KaDynamicType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaDynamicType : KaType
KaDynamicType represents a dynamic type, which is used to support interoperability with dynamically typed libraries, platforms, or languages.
KaErrorType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaErrorType : KaType
KaErrorType represents a type that failed to resolve correctly.
KaFlexibleType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaFlexibleType : KaType
KaFlexibleType represents a flexible type (or a so-called platform type), a range of types from the lowerBound to the upperBound (both inclusive).
KaFunctionType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaFunctionType : KaClassType, KaContextReceiversOwner
KaFunctionType represents a Kotlin function type, such as (String) -> Int or suspend () -> List<Any>.
KaFunctionTypeFamily¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaFunctionTypeFamily
Describes a family of numbered function types such as Function0, Function1, ..., FunctionN.
KaFunctionValueParameter¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaFunctionValueParameter : KaLifetimeOwner
Represents a function value parameter
KaIntersectionType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaIntersectionType : KaType
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¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaResolvedClassTypeQualifier : KaClassTypeQualifier
A successfully resolved KaClassTypeQualifier.
KaStandardTypeClassIds¶
object KaStandardTypeClassIds
The object contains ClassIds of well known Kotlin types.
KaStarTypeProjection¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaStarTypeProjection : KaTypeProjection
Represents a star projection (*) used in type arguments. It indicates that the specific type argument is not important or unknown.
KaSubstitutor¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaSubstitutor : KaLifetimeOwner
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¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaSubstitutorBuilder : KaLifetimeOwner
A DSL builder for KaSubstitutor.
KaSubtypingErrorTypePolicy¶
enum class KaSubtypingErrorTypePolicy : Enum<KaSubtypingErrorTypePolicy>
KaSubtypingErrorTypePolicy determines the treatment of error types in type equality and subtyping checks.
KaType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaType : KaLifetimeOwner, KaAnnotated
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¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaTypeArgumentWithVariance : KaTypeProjection
Represents a type argument with an explicit type and variance.
KaTypeMappingMode¶
enum class KaTypeMappingMode : Enum<KaTypeMappingMode>
KaTypeMappingMode determines how a Kotlin type is mapped to a Java type when calling KaType.asPsiType.
KaTypeParameterType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaTypeParameterType : KaType
KaTypeParameterType represents a type parameter type, such as T in the declaration class Box<T>(val element: T).
KaTypePointer¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaTypePointer<out T : KaType>
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¶
enum class KaUnificationSubstitutorPolicy : Enum<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¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaUnresolvedClassTypeQualifier : KaClassTypeQualifier
An unresolved KaClassTypeQualifier due to a type error.
KaUsualClassType¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
abstract class KaUsualClassType : KaClassType
KaUsualClassType represents a generic class type, such as String or List<Int>.
Properties¶
builtinFunctionTypeFamilies¶
context(session: KaSession)
val builtinFunctionTypeFamilies: KaBuiltinFunctionTypeFamilies
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¶
context(session: KaSession)
val KaClassifierSymbol.defaultType: KaType
defaultTypeWithStarProjections¶
context(session: KaSession)
val KaClassifierSymbol.defaultTypeWithStarProjections: KaType
emptySubstitutor¶
context(session: KaSession)
val emptySubstitutor: KaSubstitutor.Empty
Creates KaSubstitutor.Empty, i.e., a substitutor without any mappings.
receiverType¶
context(session: KaSession)
val KtDoubleColonExpression.receiverType: KaType?
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¶
context(session: KaSession)
val KaValueParameterSymbol.varargArrayType: KaType?
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¶
context(session: KaSession)
fun createSubstitutor(mappings: Map<KaTypeParameterSymbol, KaType>): KaSubstitutor
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.