[IR] Support user-defined equals for MFVC
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com> #KT-1179
This commit is contained in:
committed by
Space Team
parent
51f9f31a0a
commit
9f01ccc304
@@ -0,0 +1,41 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// https://youtrack.jetbrains.com/issue/KT-52236/Different-modality-in-psi-and-fir
|
||||
// WITH_STDLIB
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses, +CustomEqualsInValueClasses
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// CHECK_BYTECODE_LISTING
|
||||
|
||||
import kotlin.math.abs
|
||||
|
||||
interface I {
|
||||
fun equals(param: MFVC): Boolean
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC(val value: Int, val y: Int) : I {
|
||||
override fun equals(param: MFVC): Boolean {
|
||||
return abs(value - param.value) < 2
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a1Typed: MFVC = MFVC(1, 2)
|
||||
val b1Typed: MFVC = MFVC(2, 3)
|
||||
val c1Typed: MFVC = MFVC(3, 4)
|
||||
val a1Untyped: I = a1Typed
|
||||
val b1Untyped: I = b1Typed
|
||||
val c1Untyped: I = c1Typed
|
||||
|
||||
require(a1Typed == a1Typed && a1Untyped == a1Untyped)
|
||||
require(a1Typed == b1Typed && a1Untyped == b1Untyped)
|
||||
require(a1Typed != c1Typed && a1Untyped != c1Untyped)
|
||||
require(b1Typed == a1Typed && b1Untyped == a1Untyped)
|
||||
require(b1Typed == b1Typed && b1Untyped == b1Untyped)
|
||||
require(b1Typed == c1Typed && b1Untyped == c1Untyped)
|
||||
require(c1Typed != a1Typed && c1Untyped != a1Untyped)
|
||||
require(c1Typed == b1Typed && c1Untyped == b1Untyped)
|
||||
require(c1Typed == c1Typed && c1Untyped == c1Untyped)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user