PRIVATE_TO_THIS

Signifies that the corresponding declaration is "private-to-this", which is a non-denotable visibility of private members in Kotlin which are callable only on the same instance of the declaring class. Generally, this visibility is more restrictive than 'private', so for most use cases it can be treated the same.

Example of 'PRIVATE_TO_THIS' declaration:

class A<in T>(t: T) {
private val t: T = t // visibility for t is PRIVATE_TO_THIS

fun test() {
val x: T = t // correct
val y: T = this.t // also correct
}
fun foo(a: A<String>) {
val x: String = a.t // incorrect, because a.t can be Any
}
}

Properties

Link copied to clipboard
Link copied to clipboard