KType
Represents a type. Type is usually either a class with optional type arguments, or a type parameter of some declaration, plus nullability.
Properties
arguments
Type arguments passed for the parameters of the classifier in this type.
For example, in the type Array<out Number>
the only type argument is out Number
.
abstract val arguments: List<KTypeProjection>
classifier
The declaration of the classifier used in this type.
For example, in the type List<String>
the classifier would be the KClass instance for List.
abstract val classifier: KClassifier?
isMarkedNullable
true
if this type was marked nullable in the source code.
abstract val isMarkedNullable: Boolean
Inherited Properties
annotations
Annotations which are present on this element.
abstract val annotations: List<Annotation>
Extension Properties
javaType
Returns a Java Type instance corresponding to the given Kotlin type.
Note that one Kotlin type may correspond to different JVM types depending on where it appears. For example, Unit corresponds to
the JVM class Unit when it's the type of a parameter, or to void
when it's the return type of a function.
Extension Functions
findAnnotation
Returns an annotation of the given type on this element.
fun <T : Annotation> KAnnotatedElement.findAnnotation(): T?
findAnnotations
Returns all annotations of the given type on this element, including individually applied annotations as well as repeated annotations.
fun <T : Annotation> KAnnotatedElement.findAnnotations(): List<T>
fun <T : Annotation> KAnnotatedElement.findAnnotations(
klass: KClass<T>
): List<T>
hasAnnotation
Returns true if this element is annotated with an annotation of type T.
fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean