Files
kotlin-fork/compiler/testData/codegen/box/properties/const/intermoduleInlineConst.kt
T
Pavel Kunyavskiy 5cdda48487 [K/N] Extract const val initializers to place of usage
This would make behaviour more consistent with jvm. There is still
a difference in behaviour about point where side effects happen.

^KT-52970
2022-07-13 08:49:40 +00:00

22 lines
434 B
Kotlin
Vendored

// MODULE: lib1
// FILE: lib1.kt
object L1 {
lateinit var block: () -> Unit
}
// MODULE: lib2(lib1)
// FILE: lib2.kt
object L2 {
val sideEffect = L1.block()
const val x = 42
fun triggerInitialization() {}
}
// MODULE: main(lib1, lib2)
// FILE: main.kt
fun box(): String {
var result = 0
L1.block = { result = L2.x }
L2.triggerInitialization()
if (result != 42) return "FAIL: $result"
return "OK"
}