-
- All Implemented Interfaces:
public interface KSTypeRepresents a type in Kotlin's type system.
Generally, a type is comprised of a declaration (e.g., class), corresponding type arguments, and other details like nullability. KSType is useful when doing type checking, finding the declaration, and so on. Some of the information, such as type annotations and type arguments, are often available in the corresponding type reference without resolution.
-
-
Method Summary
Modifier and Type Method Description abstract BooleanisAssignableFrom(KSType that)Check whether this type is assign-compatible from another type. abstract BooleanisMutabilityFlexible()True if the type is a collection and can be both mutable and immutable, depending on the context. abstract BooleanisCovarianceFlexible()True if the type can be both invariant and covariant, depending on the context. abstract KSTypereplace(List<KSTypeArgument> arguments)Replace the type arguments abstract KSTypestarProjection()Returns the star projection of the type. abstract KSTypemakeNullable()Make the type nullable abstract KSTypemakeNotNullable()Make the type not nullable abstract KSDeclarationgetDeclaration()The declaration that generates this type. abstract NullabilitygetNullability()A type can be nullable, not nullable, or context-specific in the case of platform types. abstract List<KSTypeArgument>getArguments()Type arguments to the type. abstract Sequence<KSAnnotation>getAnnotations()Type annotations to the type. abstract BooleanisMarkedNullable()True if the type is explicitly marked as nullable type, i.e. abstract BooleanisError()True if the type is an error type, which means the type can't be resolved by compiler. abstract BooleanisFunctionType()True if the type is a function type. abstract BooleanisSuspendFunctionType()True if the type is a suspend function -
-
Method Detail
-
isAssignableFrom
abstract Boolean isAssignableFrom(KSType that)
Check whether this type is assign-compatible from another type.
-
isMutabilityFlexible
abstract Boolean isMutabilityFlexible()
True if the type is a collection and can be both mutable and immutable, depending on the context.
-
isCovarianceFlexible
abstract Boolean isCovarianceFlexible()
True if the type can be both invariant and covariant, depending on the context.
-
replace
abstract KSType replace(List<KSTypeArgument> arguments)
Replace the type arguments
-
starProjection
abstract KSType starProjection()
Returns the star projection of the type.
-
makeNullable
abstract KSType makeNullable()
Make the type nullable
-
makeNotNullable
abstract KSType makeNotNullable()
Make the type not nullable
-
getDeclaration
abstract KSDeclaration getDeclaration()
The declaration that generates this type.
-
getNullability
abstract Nullability getNullability()
A type can be nullable, not nullable, or context-specific in the case of platform types.
-
getArguments
abstract List<KSTypeArgument> getArguments()
Type arguments to the type.
-
getAnnotations
abstract Sequence<KSAnnotation> getAnnotations()
Type annotations to the type.
-
isMarkedNullable
abstract Boolean isMarkedNullable()
True if the type is explicitly marked as nullable type, i.e. has question mark in type declaration.
-
isError
abstract Boolean isError()
True if the type is an error type, which means the type can't be resolved by compiler.
-
isFunctionType
abstract Boolean isFunctionType()
True if the type is a function type. Note that a suspend function will return false here.
-
isSuspendFunctionType
abstract Boolean isSuspendFunctionType()
True if the type is a suspend function
-
-
-
-