Files
kotlin-fork/compiler/testData/codegen/box/properties/eagerInitializationGlobal1.kt
T
Ilya Goncharov f48436b35e rra/ilgonmic/eager-like-native
[JS IR] Leave JsEagerInitialization until bootstrap update

[JS IR] Fix js stdlib api

[JS IR] Change annotation on eager initialization in sources

[JS IR] Make eager initialization consistent with native

Merge-request: KT-MR-5030
2021-11-22 12:45:37 +00:00

28 lines
483 B
Kotlin
Vendored

// TARGET_BACKEND: JS_IR
// IGNORE_BACKEND: WASM
// PROPERTY_LAZY_INITIALIZATION
// FILE: lib.kt
var z1 = false
var z2 = false
// FILE: lib2.kt
@OptIn(kotlin.ExperimentalStdlibApi::class)
@EagerInitialization
val x = foo()
private fun foo(): Int {
z1 = true
return 42
}
// Will be initialized since [x]'s initializer calls a function from the file.
val y = run { z2 = true; 117 }
// FILE: main.kt
fun box(): String {
return return if (z1 && z2) "OK" else "fail"
}