mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Three modes: - 'disable' (default): normalize constructor calls in coroutines only (required because uninitialized objects can't be stored in fields), don't insert additional code for forced class initialization; - 'enable': normalize constructor calls, don't insert additional code for forced class initialization; - 'preserve-class-initialization': normalize constructor calls, insert additional code for forced class initialization.
42 lines
829 B
Kotlin
Vendored
42 lines
829 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// WITH_RUNTIME
|
|
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=preserve-class-initialization
|
|
// FILE: test.kt
|
|
fun box(): String {
|
|
Foo(
|
|
logged("i", 1.let { it }),
|
|
logged("j",
|
|
Foo(
|
|
logged("k", 2.let { it }),
|
|
null
|
|
)
|
|
)
|
|
)
|
|
|
|
val result = log.toString()
|
|
if (result != "<clinit>ik<init>j<init>") return "Fail: '$result'"
|
|
|
|
return "OK"
|
|
}
|
|
|
|
// FILE: util.kt
|
|
val log = StringBuilder()
|
|
|
|
fun <T> logged(msg: String, value: T): T {
|
|
log.append(msg)
|
|
return value
|
|
}
|
|
|
|
// FILE: Foo.kt
|
|
class Foo(i: Int, j: Foo?) {
|
|
init {
|
|
log.append("<init>")
|
|
}
|
|
|
|
companion object {
|
|
init {
|
|
log.append("<clinit>")
|
|
}
|
|
}
|
|
}
|