Files
kotlin/compiler/testData/codegen/box/reflection/callBy/privateMemberFunction.kt
Mads Ager 1b1dff9191 JVM_IR: fix default argument stub visibility.
Match the rules from the old backend:

1. Private and inline only methods get package private default
   argument stubs.

2. Everything else is public.
2020-01-08 13:19:14 +01:00

33 lines
615 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.full.IllegalCallableAccessException
import kotlin.reflect.jvm.isAccessible
class A {
private fun foo(default: Any? = this) {
}
fun f() = A::foo
}
fun box(): String {
val a = A()
val f = a.f()
try {
f.callBy(mapOf(f.parameters.first() to a))
return "Fail: IllegalCallableAccessException should have been thrown"
}
catch (e: IllegalCallableAccessException) {
// OK
}
f.isAccessible = true
f.callBy(mapOf(f.parameters.first() to a))
return "OK"
}