Files
kotlin-fork/js/js.translator/testData/inline/cases/innerOuterThis.kt
T
Alexey Andreev 8ad339836d KT-11875 Moves code that uncovers the following JS function:
```
function foo (closureParam, closureParam2, ...) {
    return function() {
        // function body
    }
}
```

from FunctionContext to FunctionInlineMutator. The old code causes bug when calling this function like this: `foo(this, ...)`, since first `closureParam` is replaced with `this`. Later, FunctionInlineMutator can't make difference between original `this` inside *function body* and former `closureParam` reference that became `this` after replacement. So, let FunctionInlineMutator replace `this` in *function body* and then substitute closure parameters.

KT-11875 Fixed
2016-04-15 17:35:30 +03:00

19 lines
282 B
Kotlin
Vendored

package foo
inline fun<T> with1(value: T, p: T.() -> Unit) = value.p()
class A(val expected: String) {
val b = B()
fun foo(): A {
with1(b) {
y = expected
}
return this
}
}
class B() {
var y = ""
}
fun box() = A("OK").foo().b.y