Files
kotlin-fork/compiler/testData/codegen/boxWithStdlib/reflection/properties/callPrivatePropertyFromGetProperties.kt
T

20 lines
418 B
Kotlin

import kotlin.reflect.*
import kotlin.reflect.jvm.*
class K(private val value: String)
fun box(): String {
val p = javaClass<K>().kotlin.properties.single() as KMemberProperty<K, String>
try {
return p.get(K("Fail: private property should not be accessible by default"))
}
catch (e: IllegalPropertyAccessException) {
// OK
}
p.accessible = true
return p.get(K("OK"))
}