Write outer class info for closures

This commit is contained in:
Mikhael Bogdanov
2014-05-26 13:05:36 +04:00
parent 9773015548
commit 69ef648005
20 changed files with 413 additions and 28 deletions
@@ -0,0 +1,18 @@
fun box(): String {
val objectInLambda = {
object : Any () {}
}()
val enclosingMethod = objectInLambda.javaClass.getEnclosingMethod()
if (enclosingMethod?.getName() != "invoke") return "method: $enclosingMethod"
val enclosingClass = objectInLambda.javaClass.getEnclosingClass()
if (enclosingClass?.getName() != "_DefaultPackage\$box\$objectInLambda\$1") return "enclosing class: $enclosingClass"
//KT-5092
//val declaringClass = objectInLambda.javaClass.getDeclaringClass()
//if (declaringClass == null) return "anonymous object hasn't a declaring class"
return "OK"
}