feat(JsCode): inline usage of js code which captures kotlin variables.

This commit is contained in:
Artem Kobzar
2022-02-04 15:08:22 +00:00
committed by Space
parent 96cee0f917
commit 33918156e1
13 changed files with 253 additions and 91 deletions
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// EXPECTED_REACHABLE_NODES: 1282
package foo
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// EXPECTED_REACHABLE_NODES: 1282
package foo
-1
View File
@@ -1,5 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1282
// IGNORE_BACKEND: JS_IR
package foo
fun box(): String {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// EXPECTED_REACHABLE_NODES: 1285
package foo
@@ -1,5 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1282
// IGNORE_BACKEND: JS_IR
package foo
// CHECK_LABELS_COUNT: function=box name=block count=2
+7 -3
View File
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// KJS_WITH_FULL_RUNTIME
// EXPECTED_REACHABLE_NODES: 1687
external fun p(m: String): String
@@ -26,9 +24,15 @@ fun test4(): String {
return js("p('test4')")
}
fun f() = js("p('test5')")
fun test5(): String {
val p = "wrong5"
fun f() = js("p('test5')")
// The behavoiur of the classical backend is weird and buggy
// From the user side, the local variable `p` is captured
// but we have different behaviour because the renaming phase in classical backend
// will be invoked after the lambda will be moved up
// fun f() = js("p('test5')")
return f()
}