mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 08:31:30 +00:00
Additional constructor call normalization tests
This commit is contained in:
41
compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt
vendored
Normal file
41
compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=enable
|
||||
// FILE: test.kt
|
||||
fun box(): String {
|
||||
Foo(
|
||||
logged("i", listOf(1, 2, 3).map { it + 1 }.first()),
|
||||
logged("j",
|
||||
Foo(
|
||||
logged("k", listOf(1, 2, 3).map { it + 1 }.first()),
|
||||
null
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val result = log.toString()
|
||||
if (result != "ik<clinit><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>")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user