KaTypeInformationProvider¶
@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaTypeInformationProvider : KaSessionComponent
Inheritors¶
Properties¶
builtinFunctionTypeFamilies¶
abstract val builtinFunctionTypeFamilies: KaBuiltinFunctionTypeFamilies
Provides access to the built-in function type families.
defaultInitializer¶
abstract val KaType.defaultInitializer: String?
The default initializer for the given KaType, or null if the type is neither nullable, a primitive, nor a string.
expandedSymbol¶
abstract val KaType.expandedSymbol: KaClassSymbol?
The class symbol backing the given KaType, if available.
fullyExpandedType¶
abstract val KaType.fullyExpandedType: KaType
The type that corresponds to the given KaType with fully expanded type aliases.
Type aliases are usually expanded immediately by the compiler, so most KaTypes should already present in their expanded forms. Nonetheless, it is possible to obtain unexpanded types from the Analysis API, and fullyExpandedType may be used to expand type aliases in such types.
Example
interface Base
typealias FirstAlias = @Anno1 Base
typealias SecondAlias = @Anno2 FirstAlias
fun foo(): @Anno3 SecondAlias = TODO()
The return type of foo() will be @Anno3 @Anno2 @Anno1 Base instead of @Anno3 SecondAlias
See also
functionTypeFamily¶
abstract val KaType.functionTypeFamily: KaFunctionTypeFamily?
The function type family of the given KaType, or null if the type is not a function type.
For example, (Int) -> String belongs to the Function family, while suspend () -> Unit belongs to the SuspendFunction family.
See also
hasFlexibleNullability¶
abstract val KaType.hasFlexibleNullability: Boolean
Whether the KaType is a org.jetbrains.kotlin.analysis.api.types.KaFlexibleType / org.jetbrains.kotlin.analysis.api.types.KaDynamicType with flexible nullability or org.jetbrains.kotlin.analysis.api.types.KaErrorType with unknown nullability. Both safe and ordinary calls are valid on such types.
Note that a flexible / dynamic type has a flexible nullability when the lower bound is non-nullable and the upper bound is nullable. E.g. T! has T as the lower bound and T? as the upper bound, hence it has a flexible nullability.
isAnyType¶
isArrayOrPrimitiveArray¶
abstract val KaType.isArrayOrPrimitiveArray: Boolean
Whether the KaType is an array or a primitive array type.
isBooleanType¶
abstract val KaType.isBooleanType: Boolean
isByteType¶
abstract val KaType.isByteType: Boolean
isCharSequenceType¶
abstract val KaType.isCharSequenceType: Boolean
Whether the KaType is a CharSequence type.
isCharType¶
abstract val KaType.isCharType: Boolean
isDenotable¶
abstract val KaType.isDenotable: Boolean
Whether the KaType is denotable. A denotable type can be expressed in Kotlin code, as opposed to being only constructible via compiler type operations (such as type inference).
isDoubleType¶
abstract val KaType.isDoubleType: Boolean
isFloatType¶
abstract val KaType.isFloatType: Boolean
isFunctionalInterface¶
abstract val KaType.isFunctionalInterface: Boolean
Whether the KaType is a functional interface type, such as Runnable. Such types are also known as SAM types.
isFunctionType¶
abstract val KaType.isFunctionType: Boolean
Whether the KaType is a kotlin.Function type.
isIntType¶
isKFunctionType¶
abstract val KaType.isKFunctionType: Boolean
Whether the KaType is a kotlin.reflect.KFunction type.
isKSuspendFunctionType¶
abstract val KaType.isKSuspendFunctionType: Boolean
Whether the KaType is a KSuspendFunction type.
isLongType¶
abstract val KaType.isLongType: Boolean
isMarkedNullable¶
abstract val KaType.isMarkedNullable: Boolean
Whether the KaType is explicitly marked as nullable, i.e., is represented as T?.
Note that this property just reflects the presence of nullability in the type signature, and sometimes isMarkedNullable being false doesn't imply that the given type cannot hold null or be assigned with it.
For example, isMarkedNullable doesn't expand type aliases to check the nullability of their underlying type:
The type of x is NonMarkedNullableAlias, which is not marked as nullable. However, it still represents a nullable type and can hold null and can be assigned with that.
To explicitly check whether a type can potentially hold null, use isNullable.
isNestedArray¶
abstract val KaType.isNestedArray: Boolean
Whether the KaType is an array or a primitive array type, and its element is also an array type.
isNothingType¶
abstract val KaType.isNothingType: Boolean
isNullable¶
abstract val KaType.isNullable: Boolean
Whether a public value of the KaType can potentially be null.
If a type can be null, it means that this type is not a subtype of Any. However, it does not mean one can assign null to a variable of this type. It may be unknown whether this type can accept null.
Example
A public value of type T : Any? can potentially be null. But one cannot assign null to such a variable because the instantiated type may not be nullable.
isPrimitive¶
abstract val KaType.isPrimitive: Boolean
Whether the KaType is a primitive type.
isShortType¶
abstract val KaType.isShortType: Boolean
isStringType¶
abstract val KaType.isStringType: Boolean
isSuspendFunctionType¶
abstract val KaType.isSuspendFunctionType: Boolean
Whether the KaType is a suspend function type.
isUByteType¶
abstract val KaType.isUByteType: Boolean
isUIntType¶
abstract val KaType.isUIntType: Boolean
isULongType¶
abstract val KaType.isULongType: Boolean
isUnitType¶
abstract val KaType.isUnitType: Boolean
isUShortType¶
abstract val KaType.isUShortType: Boolean
token¶
abstract val token: KaLifetimeToken
The KaLifetimeToken which determines the lifetime of the lifetime owner.
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.