18e8896c08
Like the old backend, always leave private @JvmDefault annotated interface members (properties, methods) on the interface, just like the old backend. Fix naming, and introduce test to document the naming scheme.
63 lines
2.0 KiB
Kotlin
Vendored
63 lines
2.0 KiB
Kotlin
Vendored
// !JVM_DEFAULT_MODE: enable
|
|
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// TARGET_BACKEND: JVM
|
|
// JVM_TARGET: 1.8
|
|
// WITH_RUNTIME
|
|
|
|
interface Z {
|
|
|
|
@JvmDefault
|
|
private fun privateFun() = { "OK" }
|
|
|
|
@JvmDefault
|
|
fun callPrivateFun() = privateFun()
|
|
|
|
@JvmDefault
|
|
fun publicFun() = { "OK" }
|
|
|
|
@JvmDefault
|
|
fun funWithDefaultArgs(s: () -> Unit = {}): () -> Unit
|
|
|
|
@JvmDefault
|
|
val property: () -> Unit
|
|
get() = {}
|
|
|
|
class Nested
|
|
}
|
|
|
|
class Test : Z {
|
|
override fun funWithDefaultArgs(s: () -> Unit): () -> Unit {
|
|
return s
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
|
|
val privateFun = Test().callPrivateFun()
|
|
var enclosing = privateFun.javaClass.enclosingMethod!!
|
|
if (enclosing.name != "privateFun") return "fail 1: ${enclosing.name}"
|
|
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 2: ${enclosing.getDeclaringClass().simpleName}"
|
|
|
|
val publicFun = Test().publicFun()
|
|
enclosing = publicFun.javaClass.enclosingMethod!!
|
|
if (enclosing.name != "publicFun") return "fail 3: ${enclosing.name}"
|
|
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 4: ${enclosing.getDeclaringClass().simpleName}"
|
|
|
|
val property = Test().property
|
|
enclosing = property.javaClass.enclosingMethod!!
|
|
if (enclosing.name != "getProperty") return "fail 4: ${enclosing.name}"
|
|
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 5: ${enclosing.getDeclaringClass().simpleName}"
|
|
|
|
val defaultArgs = Test().funWithDefaultArgs()
|
|
enclosing = defaultArgs.javaClass.enclosingMethod!!
|
|
if (enclosing.name != "funWithDefaultArgs\$default") return "fail 6: ${enclosing.name}"
|
|
if (enclosing.parameterTypes.size != 4) return "fail 7: not default method ${enclosing.name}"
|
|
if (enclosing.getDeclaringClass().simpleName != "Z") return "fail 8: ${enclosing.getDeclaringClass().simpleName}"
|
|
|
|
val nested = Z.Nested::class.java
|
|
val enclosingClass = nested.enclosingClass!!
|
|
if (enclosingClass.name != "Z") return "fail 9: ${enclosingClass.name}"
|
|
|
|
return "OK"
|
|
}
|