JS backend: fixed the variable capturing in deeply nested functions which mixed with the object declaration.

(cherry picked from commit 41cb0ab)
This commit is contained in:
develar
2012-09-06 18:30:58 +04:00
committed by Zalim Bashorov
parent 4a37d56a1b
commit 462e1bdc98
3 changed files with 38 additions and 26 deletions
@@ -0,0 +1,28 @@
package foo
fun getLastFocused(callback: (window: Any?)->Unit) {
callback(null)
}
abstract class TabService(val ctorParam: String) {
abstract fun query(callback: (tabs: String)->Unit)
}
abstract class PageManager(val tabService: TabService)
class ChromePageManager(val expected: String) : PageManager(object : TabService(expected) {
override fun query(callback: (tabs: String)->Unit) {
getLastFocused {
callback(expected)
}
}
})
fun box(): Boolean {
var result = ""
val tabService = ChromePageManager("result").tabService
tabService.query {
result = it
}
return result == "result" && tabService.ctorParam == "result"
}