[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,29 @@
// LANGUAGE: +ValueClassesSecondaryConstructorWithBody
// TARGET_BACKEND: JVM_IR
// CHECK_BYTECODE_LISTING
// WITH_STDLIB
// FIR_IDENTICAL
val l = mutableListOf<Any>()
@JvmInline
value class VC(val x: Int) {
constructor(xD: Double): this(-xD.toInt()) {
l.add(xD)
l.add(x)
l.add(this)
}
init {
l.add(x)
l.add(this)
}
}
fun box(): String {
val vc = VC(1)
require(vc == VC(-1.0)) { "$vc\n${VC(-1.0)}"}
val actual = listOf(1, vc, 1, vc, -1.0, 1, vc)
require(l == actual) { "$l\n$actual" }
return "OK"
}
@@ -0,0 +1,28 @@
@kotlin.Metadata
public final class SecondaryConstructorsWithBodyKt {
// source: 'secondaryConstructorsWithBody.kt'
private final static @org.jetbrains.annotations.NotNull field l: java.util.List
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getL(): java.util.List
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class VC {
// source: 'secondaryConstructorsWithBody.kt'
private final field x: int
private synthetic method <init>(p0: int): void
public synthetic final static method box-impl(p0: int): VC
public static method constructor-impl(p0: double): int
public static method constructor-impl(p0: int): int
public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: int, p1: java.lang.Object): boolean
public final static method equals-impl0(p0: int, p1: int): boolean
public final method getX(): int
public method hashCode(): int
public static method hashCode-impl(p0: int): int
public method toString(): java.lang.String
public static method toString-impl(p0: int): java.lang.String
public synthetic final method unbox-impl(): int
}
@@ -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"
}
@@ -0,0 +1,31 @@
@kotlin.Metadata
public final class SecondaryConstructorsWithBodyKt {
// source: 'secondaryConstructorsWithBody.kt'
private final static @org.jetbrains.annotations.NotNull field l: java.util.List
static method <clinit>(): void
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static @org.jetbrains.annotations.NotNull method getL(): java.util.List
}
@kotlin.jvm.JvmInline
@kotlin.Metadata
public final class VC {
// source: 'secondaryConstructorsWithBody.kt'
private final field x: int
private final field y: long
private synthetic method <init>(p0: int, p1: long): void
public synthetic final static method box-impl(p0: int, p1: long): VC
public final static @org.jetbrains.annotations.NotNull method constructor-impl(p0: double, p1: double): VC
public final static method constructor-impl(p0: int, p1: long): void
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
public static method equals-impl(p0: int, p1: long, p2: java.lang.Object): boolean
public final static method equals-impl0(p0: int, p1: long, p2: int, p3: long): boolean
public final method getX(): int
public final method getY-s-VKNKU(): long
public method hashCode(): int
public static method hashCode-impl(p0: int, p1: long): int
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
public static method toString-impl(p0: int, p1: long): java.lang.String
public synthetic final method unbox-impl-x(): int
public synthetic final method unbox-impl-y(): long
}