Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt
T
Ilmir Usmanov 999604541e JVM_IR: Support init blocks in inline classes
Put their content to constructor-impl, so they are called during
constructor call, but they are not called during boxing, because
box-impl calls <init> and not constructor-impl.

 #KT-28055 In progress
2020-10-29 20:38:01 +01:00

24 lines
367 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM
// IGNORE_BACKEND: JS_IR
// IGNORE_LIGHT_ANALYSIS
inline class IC(val i: Int) {
init {
counter += i
}
}
var counter = 0
fun <T> id(t: T) = t
fun box(): String {
val ic = IC(42)
if (counter != 42) return "FAIL 1: $counter"
counter = 0
id(ic)
if (counter != 0) return "FAIL 2: $counter"
return "OK"
}