Files
kotlin-fork/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt
T
Alexander Udalov a38a396a43 Remove default import "kotlin.reflect"
Basic reflection is usable without any imports (with :: literals)

This reverts commit 9503056dd5.
2014-07-02 01:55:53 +04:00

29 lines
601 B
Kotlin

import kotlin.reflect.KMemberProperty
import kotlin.reflect.jvm.accessible
class Result {
private val value = "OK"
fun ref(): KMemberProperty<Result, String> = ::value
}
fun box(): String {
val p = Result().ref()
try {
p.get(Result())
return "Fail: private property is accessible by default"
} catch(e: IllegalAccessException) { }
p.accessible = true
val r = p.get(Result())
p.accessible = false
try {
p.get(Result())
return "Fail: setAccessible(false) had no effect"
} catch(e: IllegalAccessException) { }
return r
}