@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class PurelyImplements(val value: String)(source)

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.


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
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

Since Kotlin



Link copied to clipboard
Since Kotlin 1.0