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"
|
||||
}
|
||||
+5
@@ -454,6 +454,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/callableReference/property/overriddenInSubclass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateClassVal.kt")
|
||||
public void testPrivateClassVal() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleExtension.kt")
|
||||
public void testSimpleExtension() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleExtension.kt");
|
||||
|
||||
Reference in New Issue
Block a user