[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
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// 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"
|
||||
}
|
||||
Reference in New Issue
Block a user