JS: fix bug in temporary variable eliminator

The problem was in considering `a` as trivial in following case:

```
var a = b;
```

However, that's wrong assumption, since `b` can be temporary variable
itself which is further substituted by a non-trivial expression.
This commit is contained in:
Alexey Andreev
2017-08-24 16:18:55 +03:00
parent abb254297a
commit 989cebe79e
3 changed files with 38 additions and 1 deletions
@@ -0,0 +1,31 @@
// EXPECTED_REACHABLE_NODES: 1002
var log = ""
fun bar(): A {
log += "foo;"
return A()
}
class A {
fun f() {
log += "f;"
}
fun g() {
log += "g;"
}
}
inline fun <T> with(x: T, a: T.() -> Unit) = x.a()
fun box(): String {
with(bar()) {
f()
g()
}
if (log != "foo;f;g;") return "fail: $log"
return "OK"
}