a8e2893494
This works in many cases, however, it is incomplete since there are cases where classes are extracted to top-level and therefore reparented. Therefore, we lose the information about the function class are nested inside.
21 lines
570 B
Kotlin
Vendored
21 lines
570 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
|
|
// WITH_REFLECT
|
|
|
|
val l: Any
|
|
get() = {}
|
|
|
|
fun box(): String {
|
|
|
|
val enclosingMethod = l.javaClass.getEnclosingMethod()
|
|
if (enclosingMethod?.getName() != "getL") return "method: $enclosingMethod"
|
|
|
|
val enclosingClass = l.javaClass.getEnclosingClass()!!.getName()
|
|
if (enclosingClass != "LambdaInPropertyGetterKt") return "enclosing class: $enclosingClass"
|
|
|
|
val declaringClass = l.javaClass.getDeclaringClass()
|
|
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
|
|
|
|
return "OK"
|
|
}
|