Fail with IllegalAccessException on :: reference to private property
Instead of mysterious NoSuchMethodException
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user