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