PurelyImplements

Platform and version requirements: JVM (1.0)
@Target([AnnotationTarget.CLASS]) annotation class PurelyImplements

Instructs the Kotlin compiler to treat annotated Java class as pure implementation of given Kotlin interface. "Pure" means here that each type parameter of class becomes non-platform type argument of that interface.

Example:

class MyList<T> extends AbstractList<T> { ... }

Methods defined in MyList<T> use T as platform, i.e. it's possible to perform unsafe operation in Kotlin:

MyList<Int>().add(null) // compiles
@PurelyImplements("kotlin.collections.MutableList")
class MyPureList<T> extends AbstractList<T> { ... }

Methods defined in MyPureList<T> overriding methods in MutableList use T as non-platform types:

MyPureList<Int>().add(null) // Error
MyPureList<Int?>().add(null) // Ok

Constructors

Platform and version requirements: JVM (1.0)

<init>

Instructs the Kotlin compiler to treat annotated Java class as pure implementation of given Kotlin interface. "Pure" means here that each type parameter of class becomes non-platform type argument of that interface.

PurelyImplements(value: String)

Properties

Platform and version requirements: JVM (1.0)

value

val value: String

Extension Properties

Platform and version requirements: JVM (1.0)

annotationClass

Returns a KClass instance corresponding to the annotation type of this annotation.

val <T : Annotation> T.annotationClass: KClass<out T>

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-purely-implements/index.html