Fail with IllegalAccessException on :: reference to private property

Instead of mysterious NoSuchMethodException
This commit is contained in:
Alexander Udalov
2014-06-05 16:51:25 +04:00
parent a8e1de48b8
commit 1275c84f92
4 changed files with 34 additions and 2 deletions
@@ -0,0 +1,15 @@
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) { }
return "OK"
}