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,17 @@
val l: Any = {}
fun box(): String {
val enclosingClass = l.javaClass.getEnclosingClass()
if (!enclosingClass!!.getName().startsWith("_DefaultPackage-lambdaInPackage-")) return "enclosing class: $enclosingClass"
val enclosingConstructor = l.javaClass.getEnclosingConstructor()
if (enclosingConstructor != null) return "enclosing constructor found: $enclosingConstructor"
val enclosingMethod = l.javaClass.getEnclosingMethod()
if (enclosingMethod != null) return "enclosing method found: $enclosingMethod"
val declaringClass = l.javaClass.getDeclaringClass()
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
return "OK"
}