[FE1.0, FIR] Support secondary constructors for Value Classes

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

#KT-1179
This commit is contained in:
Evgeniy.Zhelenskiy
2022-10-13 19:18:08 +02:00
committed by Space Team
parent 8c3fa6f09f
commit 6107caa8e2
18 changed files with 296 additions and 93 deletions
@@ -80,7 +80,7 @@ object FirInlineClassDeclarationChecker : FirRegularClassChecker() {
primaryConstructorParametersByName.map { (_, parameter) -> parameter.symbol }.toSet() primaryConstructorParametersByName.map { (_, parameter) -> parameter.symbol }.toSet()
} }
innerDeclaration.body != null -> { innerDeclaration.body != null && !context.languageVersionSettings.supportsFeature(LanguageFeature.ValueClassesSecondaryConstructorWithBody) -> {
val body = innerDeclaration.body!! val body = innerDeclaration.body!!
reporter.reportOn( reporter.reportOn(
body.source, FirErrors.SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS, context body.source, FirErrors.SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS, context
@@ -263,11 +263,13 @@ class ReservedMembersAndConstructsForInlineClass : DeclarationChecker {
} }
is ConstructorDescriptor -> { is ConstructorDescriptor -> {
val secondaryConstructor = declaration as? KtSecondaryConstructor ?: return if (!context.languageVersionSettings.supportsFeature(LanguageFeature.ValueClassesSecondaryConstructorWithBody)) {
val bodyExpression = secondaryConstructor.bodyExpression val secondaryConstructor = declaration as? KtSecondaryConstructor ?: return
if (secondaryConstructor.hasBlockBody() && bodyExpression is KtBlockExpression) { val bodyExpression = secondaryConstructor.bodyExpression
val lBrace = bodyExpression.lBrace ?: return if (secondaryConstructor.hasBlockBody() && bodyExpression is KtBlockExpression) {
context.trace.report(Errors.SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS.on(lBrace)) val lBrace = bodyExpression.lBrace ?: return
context.trace.report(Errors.SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS.on(lBrace))
}
} }
} }
} }
@@ -1,10 +1,9 @@
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses // LANGUAGE: +ValueClasses, +ValueClassesSecondaryConstructorWithBody
OPTIONAL_JVM_INLINE_ANNOTATION OPTIONAL_JVM_INLINE_ANNOTATION
value class IC private constructor(val i: Int) { value class IC private constructor(val i: Int) {
@Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
constructor() : this(0) { constructor() : this(0) {
counter += 1 counter += 1
} }
@@ -1,10 +1,9 @@
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter // LANGUAGE: +ValueClasses, +GenericInlineClassParameter, +ValueClassesSecondaryConstructorWithBody
OPTIONAL_JVM_INLINE_ANNOTATION OPTIONAL_JVM_INLINE_ANNOTATION
value class IC<T: Int> private constructor(val i: T) { value class IC<T: Int> private constructor(val i: T) {
@Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
constructor() : this(0 as T) { constructor() : this(0 as T) {
counter += 1 counter += 1
} }
@@ -1,8 +1,6 @@
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses // LANGUAGE: +ValueClasses, +ValueClassesSecondaryConstructorWithBody
@file:Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
var global = "wrong" var global = "wrong"
@@ -1,8 +1,6 @@
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter // LANGUAGE: +ValueClasses, +GenericInlineClassParameter, +ValueClassesSecondaryConstructorWithBody
@file:Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
var global = "wrong" var global = "wrong"
@@ -1,6 +1,6 @@
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses // LANGUAGE: +ValueClasses, +ValueClassesSecondaryConstructorWithBody
var global = "wrong" var global = "wrong"
@@ -10,7 +10,6 @@ value class Foo(val x: Int) {
constructor(z: Long) : this(z.toInt() + 1) constructor(z: Long) : this(z.toInt() + 1)
@Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
constructor(other: Char) : this(other.toInt().toString()) { constructor(other: Char) : this(other.toInt().toString()) {
global = "OK" global = "OK"
} }
@@ -1,6 +1,6 @@
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter // LANGUAGE: +ValueClasses, +GenericInlineClassParameter, +ValueClassesSecondaryConstructorWithBody
var global = "wrong" var global = "wrong"
@@ -10,7 +10,6 @@ value class Foo<T: Int>(val x: T) {
constructor(z: Long) : this((z.toInt() + 1) as T) constructor(z: Long) : this((z.toInt() + 1) as T)
@Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
constructor(other: Char) : this(other.toInt().toString()) { constructor(other: Char) : this(other.toInt().toString()) {
global = "OK" global = "OK"
} }
@@ -4,9 +4,7 @@
// IGNORE_BACKEND: JS_IR_ES6 // IGNORE_BACKEND: JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses // LANGUAGE: +ValueClasses, +ValueClassesSecondaryConstructorWithBody
@file:Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
OPTIONAL_JVM_INLINE_ANNOTATION OPTIONAL_JVM_INLINE_ANNOTATION
value class Foo(val x: String) { value class Foo(val x: String) {
@@ -4,9 +4,7 @@
// IGNORE_BACKEND: JS_IR_ES6 // IGNORE_BACKEND: JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter // LANGUAGE: +ValueClasses, +GenericInlineClassParameter, +ValueClassesSecondaryConstructorWithBody
@file:Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
OPTIONAL_JVM_INLINE_ANNOTATION OPTIONAL_JVM_INLINE_ANNOTATION
value class Foo<T: String>(val x: T) { value class Foo<T: String>(val x: T) {
+13 -3
View File
@@ -6,20 +6,26 @@
// TARGET_BACKEND: JVM_IR // TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND: ANDROID, ANDROID_IR // IGNORE_BACKEND: ANDROID, ANDROID_IR
// WORKS_WHEN_VALUE_CLASS // WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses // LANGUAGE: +ValueClasses, +ValueClassesSecondaryConstructorWithBody
@JvmInline @JvmInline
value class A<T : Any>(val x: List<T>) value class A<T : Any>(val x: List<T>)
@JvmInline @JvmInline
value class B(val x: UInt) value class B(val x: UInt) {
constructor(x: String) : this(x.toUInt()) {
supply(x)
}
}
@JvmInline @JvmInline
value class C(val x: Int, val y: B, val z: String = "3") value class C(val x: Int, val y: B, val z: String = "3")
@JvmInline @JvmInline
value class D(val x: C) { value class D(val x: C) {
constructor(x: Int, y: UInt, z: Int) : this(C(x, B(y), z.toString())) constructor(x: Int, y: UInt, z: Int) : this(C(x, B(y), z.toString())) {
supply(y)
}
init { init {
supply(x.x) supply(x.x)
@@ -69,6 +75,7 @@ fun <T : List<Int>> h(r: R<T>) {
g(r.z) g(r.z)
f(r) f(r)
r r
require(B("3") == B(3U))
C(2, B(3U), "") C(2, B(3U), "")
D(C(2, B(3U), "")) D(C(2, B(3U), ""))
val x = D(C(2, B(3U), "")) val x = D(C(2, B(3U), ""))
@@ -227,6 +234,7 @@ fun box(): String {
1 1
#3 #3
3 3
4
#4 #4
#5 #5
R(x=1, y=2, z=E(x=D(x=C(x=3, y=B(x=4), z=5))), t=A(x=[[6]])) R(x=1, y=2, z=E(x=D(x=C(x=3, y=B(x=4), z=5))), t=A(x=[[6]]))
@@ -257,12 +265,14 @@ fun box(): String {
B(x=4) B(x=4)
5 5
4 4
3
2 2
2 2
4 4
D(x=C(x=4, y=B(x=5), z=1)) D(x=C(x=4, y=B(x=5), z=1))
6 6
6 6
7
6 6
6 6
D(x=C(x=6, y=B(x=7), z=2)) D(x=C(x=6, y=B(x=7), z=2))
@@ -24,6 +24,7 @@ public final class B {
private final field x: int private final field x: int
private synthetic method <init>(p0: int): void private synthetic method <init>(p0: int): void
public synthetic final static method box-impl(p0: int): B public synthetic final static method box-impl(p0: int): B
public static method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.String): int
public static method constructor-impl(p0: int): int public static method constructor-impl(p0: int): int
public method equals(p0: java.lang.Object): boolean public method equals(p0: java.lang.Object): boolean
public static method equals-impl(p0: int, p1: java.lang.Object): boolean public static method equals-impl(p0: int, p1: java.lang.Object): boolean
@@ -1,18 +1,21 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +CustomEqualsInInlineClasses // WITH_STDLIB
// !LANGUAGE: +CustomEqualsInValueClasses
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
inline class IC1(val x: Any) { @JvmInline
value class IC1(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>() {} fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {} fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>() {} fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {} fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
override fun <!INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS!>equals<!>(other: Any?): Boolean = true override fun <!INEFFICIENT_EQUALS_OVERRIDING_IN_VALUE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun hashCode(): Int = 0 override fun hashCode(): Int = 0
} }
inline class IC2(val x: Any) { @JvmInline
value class IC2(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {} fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): Any = TODO() fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): Any = TODO()
@@ -23,7 +26,8 @@ inline class IC2(val x: Any) {
fun hashCode(a: Any): Int = 0 fun hashCode(a: Any): Int = 0
} }
inline class IC3(val x: Any) { @JvmInline
value class IC3(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any): Any = TODO() fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any): Any = TODO() fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any): Any = TODO()
@@ -34,12 +38,34 @@ interface WithBox {
fun box(): String fun box(): String
} }
inline class IC4(val s: String) : WithBox { @JvmInline
value class IC4(val s: String) : WithBox {
override fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): String = "" override fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): String = ""
} }
inline class IC5(val a: String) { @JvmInline
value class IC5(val a: String) {
constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{ constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{
TODO("something") TODO("something")
}<!> }<!>
} }
@JvmInline
value class IC6(val a: String) {
fun <!TYPE_PARAMETERS_NOT_ALLOWED!><T><!> equals(other: IC6): Boolean = true
}
@JvmInline
value class IC7<T>(val a: String) {
fun equals(other: IC7<*>): Boolean = true
}
@JvmInline
value class IC8<T>(val a: String) {
fun equals(other: <!TYPE_ARGUMENT_ON_TYPED_VALUE_CLASS_EQUALS!>IC8<T><!>): Boolean = true
}
@JvmInline
value class IC9<T>(val a: String) {
fun equals(other: <!TYPE_ARGUMENT_ON_TYPED_VALUE_CLASS_EQUALS!>IC9<String><!>): Boolean = true
}
@@ -0,0 +1,125 @@
// !SKIP_JAVAC
// !LANGUAGE: +CustomEqualsInValueClasses, +ValueClasses
// ALLOW_KOTLIN_PACKAGE
// !DIAGNOSTICS: -UNUSED_PARAMETER
package kotlin.jvm
annotation class JvmInline
@JvmInline
value class IC1(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
override fun <!INEFFICIENT_EQUALS_OVERRIDING_IN_VALUE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun hashCode(): Int = 0
}
@JvmInline
value class IC2(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(): Any = TODO()
fun equals(my: Any, other: Any): Boolean = true
fun hashCode(a: Any): Int = 0
}
@JvmInline
value class IC3(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any): Any = TODO()
fun equals(): Boolean = true
}
interface WithBox {
fun box(): String
}
@JvmInline
value class IC4(val s: String) : WithBox {
override fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): String = ""
}
@JvmInline
value class IC5(val a: String) {
constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{
TODO("something")
}<!>
}
@JvmInline
value class IC6(val a: String) {
fun <!TYPE_PARAMETERS_NOT_ALLOWED!><T><!> equals(other: IC6): Boolean = true
}
@JvmInline
value class MFVC1(val x: Any, val y: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
override fun <!INEFFICIENT_EQUALS_OVERRIDING_IN_VALUE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun hashCode(): Int = 0
}
@JvmInline
value class MFVC2(val x: Any, val y: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(): Any = TODO()
fun equals(my: Any, other: Any): Boolean = true
fun hashCode(a: Any): Int = 0
}
@JvmInline
value class MFVC3(val x: Any, val y: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any): Any = TODO()
fun equals(): Boolean = true
}
@JvmInline
value class MFVC4(val s: String, val t: String) : WithBox {
override fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): String = ""
}
@JvmInline
value class MFVC5(val a: String, val b: String) {
constructor(i: Int) : this(i.toString(), "6") <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{
TODO("something")
}<!>
}
@JvmInline
value class MFVC6(val a: String, val b: String) {
fun <!TYPE_PARAMETERS_NOT_ALLOWED!><T><!> equals(other: MFVC6): Boolean = true
}
@JvmInline
value class MFVC7<T>(val a: String, val b: String) {
fun equals(other: MFVC7<*>): Boolean = true
}
@JvmInline
value class MFVC8<T>(val a: String, val b: String) {
fun equals(other: <!TYPE_ARGUMENT_ON_TYPED_VALUE_CLASS_EQUALS!>MFVC8<T><!>): Boolean = true
}
@JvmInline
value class MFVC9<T>(val a: String, val b: String) {
fun equals(other: <!TYPE_ARGUMENT_ON_TYPED_VALUE_CLASS_EQUALS!>MFVC9<String><!>): Boolean = true
}
@@ -0,0 +1,105 @@
// !SKIP_JAVAC
// !LANGUAGE: +CustomEqualsInInlineClasses, +ValueClasses
// ALLOW_KOTLIN_PACKAGE
// !DIAGNOSTICS: -UNUSED_PARAMETER
package kotlin.jvm
annotation class JvmInline
@JvmInline
value class IC1(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
override fun <!INEFFICIENT_EQUALS_OVERRIDING_IN_VALUE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun hashCode(): Int = 0
}
@JvmInline
value class IC2(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(): Any = TODO()
fun equals(my: Any, other: Any): Boolean = true
fun hashCode(a: Any): Int = 0
}
@JvmInline
value class IC3(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any): Any = TODO()
fun equals(): Boolean = true
}
interface WithBox {
fun box(): String
}
@JvmInline
value class IC4(val s: String) : WithBox {
override fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): String = ""
}
@JvmInline
value class IC5(val a: String) {
constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{<!>
TODO("something")
}
}
@JvmInline
value class IC6(val a: String) {
fun <!TYPE_PARAMETERS_NOT_ALLOWED!><T><!> equals(other: IC6): Boolean = true
}
@JvmInline
value class MFVC1(val x: Any, val y: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
override fun <!INEFFICIENT_EQUALS_OVERRIDING_IN_VALUE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun hashCode(): Int = 0
}
@JvmInline
value class MFVC2(val x: Any, val y: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(): Any = TODO()
fun equals(my: Any, other: Any): Boolean = true
fun hashCode(a: Any): Int = 0
}
@JvmInline
value class MFVC3(val x: Any, val y: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any): Any = TODO()
fun equals(): Boolean = true
}
@JvmInline
value class MFVC4(val s: String, val t: String) : WithBox {
override fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): String = ""
}
@JvmInline
value class MFVC5(val a: String, val b: String) {
constructor(i: Int) : this(i.toString(), "6") <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{<!>
TODO("something")
}
}
@@ -1,56 +0,0 @@
// !SKIP_JAVAC
// !LANGUAGE: +InlineClasses, +CustomEqualsInInlineClasses
// ALLOW_KOTLIN_PACKAGE
// !DIAGNOSTICS: -UNUSED_PARAMETER
package kotlin.jvm
annotation class JvmInline
@JvmInline
value class IC1(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
override fun <!INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun hashCode(): Int = 0
}
@JvmInline
value class IC2(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(): Any = TODO()
fun equals(my: Any, other: Any): Boolean = true
fun hashCode(a: Any): Int = 0
}
@JvmInline
value class IC3(val x: Any) {
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>unbox<!>(x: Any): Any = TODO()
fun equals(): Boolean = true
}
interface WithBox {
fun box(): String
}
@JvmInline
value class IC4(val s: String) : WithBox {
override fun <!RESERVED_MEMBER_INSIDE_VALUE_CLASS!>box<!>(): String = ""
}
@JvmInline
value class IC5(val a: String) {
constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{
TODO("something")
}<!>
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !SKIP_JAVAC // !SKIP_JAVAC
// !LANGUAGE: +InlineClasses, +CustomEqualsInInlineClasses // !LANGUAGE: +InlineClasses, +CustomEqualsInInlineClasses
// ALLOW_KOTLIN_PACKAGE // ALLOW_KOTLIN_PACKAGE
@@ -50,7 +51,7 @@ value class IC4(val s: String) : WithBox {
@JvmInline @JvmInline
value class IC5(val a: String) { value class IC5(val a: String) {
constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS!>{<!> constructor(i: Int) : this(i.toString()) {
TODO("something") TODO("something")
} }
} }
@@ -317,6 +317,7 @@ enum class LanguageFeature(
JavaSamConversionEqualsHashCode(sinceVersion = null, kind = UNSTABLE_FEATURE), JavaSamConversionEqualsHashCode(sinceVersion = null, kind = UNSTABLE_FEATURE),
UnitConversionsOnArbitraryExpressions(sinceVersion = null), UnitConversionsOnArbitraryExpressions(sinceVersion = null),
JsAllowImplementingFunctionInterface(sinceVersion = null, kind = UNSTABLE_FEATURE), JsAllowImplementingFunctionInterface(sinceVersion = null, kind = UNSTABLE_FEATURE),
ValueClassesSecondaryConstructorWithBody(sinceVersion = null, kind = UNSTABLE_FEATURE),
; ;
init { init {