Files
kotlin/compiler/testData/codegen/box/constructorCall/breakInConstructorArguments.kt
Dmitry Petrov 7e808bd3ea Add more tests for constructor call evaluation order
- break in arguments
- continue in arguments
- early return in arguments
- non-local return in arguments
- nested constructor call in arguments
2017-10-04 13:39:48 +03:00

39 lines
672 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: test.kt
fun box(): String {
var count = 0
while (true) {
Foo(
logged("i", if (count == 0) 1 else break),
logged("j", 2)
)
count++
}
val result = log.toString()
if (result != "<clinit>ij<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: Int) {
init {
log.append("<init>")
}
companion object {
init {
log.append("<clinit>")
}
}
}