Files
kotlin-fork/compiler/testData/codegen/box/closures/captureOuterProperty/inPropertyDeepObjectChain.kt
T
Alexander Udalov 35c7c4afd8 Fix capturing outer this in some cases in JVM codegen
When property initializer of some inner entity (e.g. anonymous object) contains
a reference to some outer entity (say, a property of the outer class), we need
to make sure we called "lookupInContext" on this entity's owner class, so that
"setCaptureThis" was called on the appropriate closure

 #KT-4176 Fixed
2014-02-12 19:17:55 +04:00

19 lines
396 B
Kotlin

trait T {
fun result(): String
}
class A(val x: String) {
fun foo() = object : T {
fun bar() = object : T {
fun baz() = object : T {
val y = x
override fun result() = y
}
override fun result() = baz().result()
}
override fun result() = bar().result()
}
}
fun box() = A("OK").foo().result()