[IR] Add tests for value classes secondary constructors with body and set language feature version for the feature

Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-55333
This commit is contained in:
Evgeniy.Zhelenskiy
2022-12-07 06:11:42 +01:00
parent 5f986fd467
commit abc1d942d1
7 changed files with 145 additions and 1 deletions
@@ -0,0 +1,32 @@
// LANGUAGE: +ValueClasses, +ValueClassesSecondaryConstructorWithBody
// TARGET_BACKEND: JVM_IR
// CHECK_BYTECODE_LISTING
// WITH_STDLIB
// FIR_IDENTICAL
val l = mutableListOf<Any>()
@JvmInline
value class VC(val x: Int, val y: ULong) {
constructor(xD: Double, yD: Double): this(xD.toInt() - 2, yD.toULong() - 2UL) {
l.add(xD)
l.add(yD)
l.add(x)
l.add(y)
l.add(this)
}
init {
l.add(x)
l.add(y)
l.add(this)
}
}
fun box(): String {
val vc = VC(1, 2UL)
require(vc == VC(3.0, 4.0)) { "$vc\n${VC(3.0, 4.0)}"}
val actual = listOf(1, 2UL, vc, 1, 2UL, vc, 3.0, 4.0, 1, 2UL, vc)
require(l == actual) { "$l\n$actual" }
return "OK"
}