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
This commit is contained in:
Alexander Udalov
2014-02-12 19:08:43 +04:00
parent 7bf26283b2
commit 35c7c4afd8
11 changed files with 201 additions and 21 deletions
@@ -0,0 +1,15 @@
trait T {
fun result(): String
}
class A(val x: String) {
fun getx() = x
fun foo() = object : T {
val bar = getx()
override fun result() = bar
}
}
fun box() = A("OK").foo().result()