Files
kotlin/compiler/testData/codegen/boxWithStdlib/reflection/enclosing/lambdaInClassObject.kt
Pavel V. Talanov 59f192ef90 Replace 'class object' with 'default object' in renderers and test data
Includes changes to decompiled text
Old syntax is used in builtins and project code for now
2015-03-06 19:36:54 +03:00

26 lines
862 B
Kotlin

class O {
default object {
// Currently we consider <clinit> in class O as the enclosing method of this lambda,
// so we write outer class = O and enclosing method = null
val f = {}
}
}
fun box(): String {
val javaClass = O.f.javaClass
val enclosingMethod = javaClass.getEnclosingMethod()
if (enclosingMethod != null) return "method: $enclosingMethod"
val enclosingConstructor = javaClass.getEnclosingConstructor()
if (enclosingConstructor != null) return "constructor: $enclosingConstructor"
val enclosingClass = javaClass.getEnclosingClass()
if (enclosingClass?.getName() != "O") return "enclosing class: $enclosingClass"
val declaringClass = javaClass.getDeclaringClass()
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
return "OK"
}