[JS IR] Add properties lazy initialization with multiple modules

[JS IR] Move tests into compiler/testData

[JS IR] Add cyclic dependencies with lazy property initialization

[JS IR] Add test on not initialization in case of call non properties (classed, objects, enum classes, const vals)

[JS IR] Add initialization through top level

[JS IR] Ignore enum getInstance function in property lazy initialization

[JS IR] Use let function with useful result instead of pure apply and also

[JS IR] Remove duplicated tests in js.translator
This commit is contained in:
Ilya Goncharov
2020-11-24 17:19:15 +03:00
parent 6cb573cb45
commit 697b2b02f1
19 changed files with 335 additions and 67 deletions
@@ -1,18 +0,0 @@
// IGNORE_BACKEND: JS
// DONT_TARGET_EXACT_BACKEND: WASM
// PROPERTY_LAZY_INITIALIZATION
// FILE: A.kt
val o = "O"
// FILE: B.kt
val ok = o + k
// FILE: C.kt
val k = "K"
// FILE: main.kt
fun box(): String = ok
@@ -1,36 +0,0 @@
// EXPECTED_REACHABLE_NODES: 1239
// DONT_TARGET_EXACT_BACKEND: WASM
// PROPERTY_LAZY_INITIALIZATION
// FILE: A.kt
val a = "A".let {
flag = !flag
if (flag) {
it
} else {
"!A"
}
}
val b = "B".let {
flag = !flag
if (!flag) {
it
} else {
"!B"
}
}
// FILE: B.kt
var flag: Boolean = false
// FILE: main.kt
fun box(): String {
return if (
a == "A" && b == "B"
)
"OK"
else "a = $a; b = ${b}"
}
@@ -1,32 +0,0 @@
// IGNORE_BACKEND: JS
// PROPERTY_LAZY_INITIALIZATION
// FILE: A.kt
val a = "A"
// FILE: B.kt
val b = "B".apply {}
val c = b
// FILE: C.kt
val d = "D".apply {}
val e = d
// FILE: main.kt
fun box(): String {
// Get only e to initialize all properties in file
e
return if (
js("a") === "A" &&
js("typeof b") == "undefined" &&
js("typeof c") == "undefined" &&
js("d") === "D" &&
js("e") === "D"
)
"OK"
else "a = ${js("a")}; typeof b = ${js("typeof b")}; typeof c = ${js("typeof c")}; d = ${js("d")}; e = ${js("e")}"
}
@@ -1,22 +0,0 @@
// IGNORE_BACKEND: JS
// DONT_TARGET_EXACT_BACKEND: WASM
// SPLIT_PER_MODULE
// PROPERTY_LAZY_INITIALIZATION
// MODULE: lib1
// FILE: A.kt
val o = "O"
// FILE: B.kt
val okCandidate = o + k
// FILE: C.kt
val k = "K"
// MODULE: lib2(lib1)
// FILE: lib2.kt
val ok = okCandidate
// MODULE: main(lib1, lib2)
// FILE: main.kt
fun box(): String = ok