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
This commit is contained in:
Alexey Andreev
2016-04-13 12:51:12 +03:00
parent 8129901d82
commit 8ad339836d
5 changed files with 68 additions and 97 deletions
@@ -0,0 +1,19 @@
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