mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 08:31:35 +00:00
Write outer class info for closures
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
|
||||
var _l: Any = ""
|
||||
|
||||
var l: Any
|
||||
get() = _l
|
||||
set(v) {
|
||||
_l = {}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
l = "" // to invoke the setter
|
||||
|
||||
val enclosingMethod = l.javaClass.getEnclosingMethod()
|
||||
if (enclosingMethod?.getName() != "setL") return "method: $enclosingMethod"
|
||||
|
||||
val enclosingClass = l.javaClass.getEnclosingClass()
|
||||
if (!enclosingClass!!.getName().startsWith("_DefaultPackage-lambdaInPropertySetter-")) return "enclosing class: $enclosingClass"
|
||||
|
||||
val declaringClass = l.javaClass.getDeclaringClass()
|
||||
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user