[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,53 @@
|
||||
// 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
|
||||
|
||||
var counter = 0
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC(val x: Int, val y: Int) {
|
||||
|
||||
fun equals(other: MFVC): Boolean {
|
||||
counter++
|
||||
return x == other.x && this.y == other.y
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
counter++
|
||||
if (other !is MFVC) {
|
||||
return false
|
||||
}
|
||||
return equals(other)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
counter++
|
||||
return x + 13 * y
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val mfvc1 = MFVC(1, 2)
|
||||
val mfvc2 = MFVC(3, 4)
|
||||
|
||||
require(mfvc1.equals(mfvc1))
|
||||
require(!mfvc1.equals(mfvc2))
|
||||
require(!mfvc2.equals(mfvc1))
|
||||
require(mfvc2.equals(mfvc2))
|
||||
|
||||
require(mfvc1.equals(mfvc1 as Any?))
|
||||
require(!mfvc1.equals(mfvc2 as Any?))
|
||||
require(!mfvc2.equals(mfvc1 as Any?))
|
||||
require(mfvc2.equals(mfvc2 as Any?))
|
||||
|
||||
require(mfvc1.hashCode() == 27)
|
||||
require(mfvc2.hashCode() == 55)
|
||||
|
||||
require(counter == 4 + 2 * 4 + 2)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC {
|
||||
// source: 'mfvcBothEqualsOverride.kt'
|
||||
private final field field-0: int
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: int, p1: int): void
|
||||
public synthetic final static method box-impl(p0: int, p1: int): MFVC
|
||||
public final static method constructor-impl(p0: int, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: int, p1: int, @org.jetbrains.annotations.Nullable p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: int, p1: int, p2: int, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: int, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: int, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): int
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MfvcBothEqualsOverrideKt {
|
||||
// source: 'mfvcBothEqualsOverride.kt'
|
||||
private static field counter: int
|
||||
static method <clinit>(): void
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static method getCounter(): int
|
||||
public final static method setCounter(p0: int): void
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// 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 java.lang.AssertionError
|
||||
import kotlin.math.abs
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC1(val x: Int, val y: Int) {
|
||||
fun equals(other: MFVC1): Boolean {
|
||||
return abs(x - other.x) < 2 && abs(y - other.y) < 2
|
||||
}
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC2(val x: Int, val y: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is MFVC2) {
|
||||
return false
|
||||
}
|
||||
return abs(x - other.x) < 2 && abs(y - other.y) < 2
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a1Typed: MFVC1 = MFVC1(1, 2)
|
||||
val b1Typed: MFVC1 = MFVC1(2, 3)
|
||||
val c1Typed: MFVC1 = MFVC1(3, 4)
|
||||
val a1Untyped: Any = a1Typed
|
||||
val b1Untyped: Any = b1Typed
|
||||
val c1Untyped: Any = c1Typed
|
||||
|
||||
val a2Typed: MFVC2 = MFVC2(1, 2)
|
||||
val b2Typed: MFVC2 = MFVC2(2, 3)
|
||||
val c2Typed: MFVC2 = MFVC2(3, 4)
|
||||
val a2Untyped: Any = a2Typed
|
||||
val b2Untyped: Any = b2Typed
|
||||
val c2Untyped: Any = c2Typed
|
||||
|
||||
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)
|
||||
|
||||
require(a2Typed == a2Typed && a2Untyped == a2Untyped)
|
||||
require(a2Typed == b2Typed && a2Untyped == b2Untyped)
|
||||
require(a2Typed != c2Typed && a2Untyped != c2Untyped)
|
||||
require(b2Typed == a2Typed && b2Untyped == a2Untyped)
|
||||
require(b2Typed == b2Typed && b2Untyped == b2Untyped)
|
||||
require(b2Typed == c2Typed && b2Untyped == c2Untyped)
|
||||
require(c2Typed != a2Typed && c2Untyped != a2Untyped)
|
||||
require(c2Typed == b2Typed && c2Untyped == b2Untyped)
|
||||
require(c2Typed == c2Typed && c2Untyped == c2Untyped)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC1 {
|
||||
// source: 'mfvcEqualsConsistency.kt'
|
||||
private final field field-0: int
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: int, p1: int): void
|
||||
public synthetic final static method box-impl(p0: int, p1: int): MFVC1
|
||||
public final static method constructor-impl(p0: int, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: int, p1: int, p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: int, p1: int, p2: int, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: int, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: int, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): int
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC2 {
|
||||
// source: 'mfvcEqualsConsistency.kt'
|
||||
private final field field-0: int
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: int, p1: int): void
|
||||
public synthetic final static method box-impl(p0: int, p1: int): MFVC2
|
||||
public final static method constructor-impl(p0: int, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: int, p1: int, @org.jetbrains.annotations.Nullable p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: int, p1: int, p2: int, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: int, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: int, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): int
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MfvcEqualsConsistencyKt {
|
||||
// source: 'mfvcEqualsConsistency.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// 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
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC(val x: Double, val y: Int) {
|
||||
fun equals(other: MFVC): Boolean {
|
||||
return abs(x - other.x) < 0.1
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val set = setOf(MFVC(1.0, 100), MFVC(1.5, 200), MFVC(1.501, 300))
|
||||
return if (set.size == 2) "OK" else "Fail"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC {
|
||||
// source: 'mfvcEqualsOverriddenForCollections.kt'
|
||||
private final field field-0: double
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: double, p1: int): void
|
||||
public synthetic final static method box-impl(p0: double, p1: int): MFVC
|
||||
public final static method constructor-impl(p0: double, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: double, p1: int, p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: double, p1: int, p2: double, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: double, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: double, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): double
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MfvcEqualsOverriddenForCollectionsKt {
|
||||
// source: 'mfvcEqualsOverriddenForCollections.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
@kotlin.Metadata
|
||||
public interface I {
|
||||
// source: 'mfvcEqualsOverride.kt'
|
||||
public abstract method equals-sUp7gFk(p0: int, p1: int): boolean
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC {
|
||||
// source: 'mfvcEqualsOverride.kt'
|
||||
private final field field-0: int
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: int, p1: int): void
|
||||
public synthetic final static method box-impl(p0: int, p1: int): MFVC
|
||||
public final static method constructor-impl(p0: int, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: int, p1: int, p2: java.lang.Object): boolean
|
||||
public method equals-sUp7gFk(p0: int, p1: int): boolean
|
||||
public static method equals-sUp7gFk(p0: int, p1: int, p2: int, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: int, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: int, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): int
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MfvcEqualsOverrideKt {
|
||||
// source: 'mfvcEqualsOverride.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class A(val value1: MyClass, val value2: MyClass) {
|
||||
override fun hashCode() = 42
|
||||
}
|
||||
|
||||
class MyClass() {
|
||||
override fun hashCode() = -1
|
||||
}
|
||||
|
||||
fun box(): String = if (A(MyClass(), MyClass()).hashCode() == 42) "OK" else "Fail"
|
||||
@@ -0,0 +1,32 @@
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class A {
|
||||
// source: 'mfvcHashCodeOverride.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field field-0: MyClass
|
||||
private final @org.jetbrains.annotations.NotNull field field-1: MyClass
|
||||
private synthetic method <init>(p0: MyClass, p1: MyClass): void
|
||||
public synthetic final static method box-impl(p0: MyClass, p1: MyClass): A
|
||||
public final static method constructor-impl(@org.jetbrains.annotations.NotNull p0: MyClass, @org.jetbrains.annotations.NotNull p1: MyClass): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: MyClass, p1: MyClass, p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: MyClass, p1: MyClass, p2: MyClass, p3: MyClass): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(@org.jetbrains.annotations.NotNull p0: MyClass, @org.jetbrains.annotations.NotNull p1: MyClass): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: MyClass, p1: MyClass): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): MyClass
|
||||
public synthetic final method unbox-impl-1(): MyClass
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MfvcHashCodeOverrideKt {
|
||||
// source: 'mfvcHashCodeOverride.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MyClass {
|
||||
// source: 'mfvcHashCodeOverride.kt'
|
||||
public method <init>(): void
|
||||
public method hashCode(): int
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// WITH_STDLIB
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses, +CustomEqualsInValueClasses
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// CHECK_BYTECODE_LISTING
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC1<T : Number>(val x: T, val other: Int) {
|
||||
fun equals(x: Int, other: Int) = false
|
||||
fun equals(other: MFVC1<*>) = true
|
||||
}
|
||||
|
||||
class Generic<T, R>(val x: T, val y: R)
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC2<T, R>(val value: Generic<T, R>, val other: Int) {
|
||||
fun equals(value: MFVC1<Double>, other: Int) = false
|
||||
fun equals(other: MFVC2<*, *>) = true
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC3<T>(val value: T, val other: Int) {
|
||||
fun equals(value: Int, other: Int) = false
|
||||
fun equals(other: MFVC3<*>) = true
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC4<T>(val value: T, val other: Int) {
|
||||
fun equals(value: Any, other: Int) = false
|
||||
fun equals(other: MFVC4<*>) = true
|
||||
}
|
||||
|
||||
|
||||
fun box() = when {
|
||||
MFVC1(5.0, 100) != MFVC1(3, 100) -> "Fail 1.1"
|
||||
(MFVC1(5.0, 100) as Any) != MFVC1(3, 100) -> "Fail 1.2"
|
||||
MFVC1(5.0, 100) != (MFVC1(3, 100) as Any) -> "Fail 1.3"
|
||||
(MFVC1(5.0, 100) as Any) != (MFVC1(3, 100) as Any) -> "Fail 1.4"
|
||||
|
||||
MFVC2(Generic("aba", 5.0), 100) != MFVC2(Generic(3, 8), 100) -> "Fail 2.1"
|
||||
(MFVC2(Generic("aba", 5.0), 100) as Any) != MFVC2(Generic(3, 8), 100) -> "Fail 2.2"
|
||||
MFVC2(Generic("aba", 5.0), 100) != (MFVC2(Generic(3, 8), 100) as Any) -> "Fail 2.3"
|
||||
(MFVC2(Generic("aba", 5.0), 100) as Any) != (MFVC2(Generic(3, 8), 100) as Any) -> "Fail 2.4"
|
||||
|
||||
MFVC3("x", 100) != MFVC3("y", 100) -> "Fail 3.1"
|
||||
(MFVC3("x", 100) as Any) != MFVC3("y", 100) -> "Fail 3.2"
|
||||
MFVC3("x", 100) != (MFVC3("y", 100) as Any) -> "Fail 3.3"
|
||||
(MFVC3("x", 100) as Any) != (MFVC3("y", 100) as Any) -> "Fail 3.4"
|
||||
|
||||
MFVC4("aba", 100) != MFVC4("caba", 100) -> "Fail 4.1"
|
||||
(MFVC4("aba", 100) as Any) != MFVC4("caba", 100) -> "Fail 4.2"
|
||||
MFVC4("aba", 100) != (MFVC4("caba", 100) as Any) -> "Fail 4.3"
|
||||
(MFVC4("aba", 100) as Any) != (MFVC4("caba", 100) as Any) -> "Fail 4.4"
|
||||
|
||||
else -> "OK"
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
@kotlin.Metadata
|
||||
public final class Generic {
|
||||
// source: 'mfvcTypedEqualsGenerics.kt'
|
||||
private final field x: java.lang.Object
|
||||
private final field y: java.lang.Object
|
||||
public method <init>(p0: java.lang.Object, p1: java.lang.Object): void
|
||||
public final method getX(): java.lang.Object
|
||||
public final method getY(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC1 {
|
||||
// source: 'mfvcTypedEqualsGenerics.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field field-0: java.lang.Number
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: java.lang.Number, p1: int): void
|
||||
public synthetic final static method box-impl(p0: java.lang.Number, p1: int): MFVC1
|
||||
public final static method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.Number, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public final static method equals-impl(@org.jetbrains.annotations.NotNull p0: java.lang.Number, p1: int, p2: int, p3: int): boolean
|
||||
public static method equals-impl(p0: java.lang.Number, p1: int, p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(@org.jetbrains.annotations.NotNull p0: java.lang.Number, p1: int, @org.jetbrains.annotations.NotNull p2: java.lang.Number, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: java.lang.Number, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: java.lang.Number, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): java.lang.Number
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC2 {
|
||||
// source: 'mfvcTypedEqualsGenerics.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field field-0: Generic
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: Generic, p1: int): void
|
||||
public synthetic final static method box-impl(p0: Generic, p1: int): MFVC2
|
||||
public final static method constructor-impl(@org.jetbrains.annotations.NotNull p0: Generic, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public final static method equals-GPBa7dw(@org.jetbrains.annotations.NotNull p0: Generic, p1: int, p2: double, p3: int, p4: int): boolean
|
||||
public static method equals-impl(p0: Generic, p1: int, p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(@org.jetbrains.annotations.NotNull p0: Generic, p1: int, @org.jetbrains.annotations.NotNull p2: Generic, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: Generic, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: Generic, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): Generic
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC3 {
|
||||
// source: 'mfvcTypedEqualsGenerics.kt'
|
||||
private final field field-0: java.lang.Object
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: java.lang.Object, p1: int): void
|
||||
public synthetic final static method box-impl(p0: java.lang.Object, p1: int): MFVC3
|
||||
public final static method constructor-impl(p0: java.lang.Object, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public final static method equals-impl(p0: java.lang.Object, p1: int, p2: int, p3: int): boolean
|
||||
public static method equals-impl(p0: java.lang.Object, p1: int, p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: java.lang.Object, p1: int, p2: java.lang.Object, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: java.lang.Object, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: java.lang.Object, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): java.lang.Object
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC4 {
|
||||
// source: 'mfvcTypedEqualsGenerics.kt'
|
||||
private final field field-0: java.lang.Object
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: java.lang.Object, p1: int): void
|
||||
public synthetic final static method box-impl(p0: java.lang.Object, p1: int): MFVC4
|
||||
public final static method constructor-impl(p0: java.lang.Object, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public final static method equals-impl(p0: java.lang.Object, p1: int, @org.jetbrains.annotations.NotNull p2: java.lang.Object, p3: int): boolean
|
||||
public static method equals-impl(p0: java.lang.Object, p1: int, p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: java.lang.Object, p1: int, p2: java.lang.Object, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: java.lang.Object, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: java.lang.Object, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): java.lang.Object
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MfvcTypedEqualsGenericsKt {
|
||||
// source: 'mfvcTypedEqualsGenerics.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// 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
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class MFVC(val x: Int, val y: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is MFVC) {
|
||||
return false
|
||||
}
|
||||
return abs(x - other.x) < 2 && abs(y - other.y) < 2
|
||||
}
|
||||
|
||||
override fun hashCode() = 0
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val set = setOf(MFVC(1, 2), MFVC(2, 3), MFVC(5, 6))
|
||||
return if (set.size == 2) "OK" else "Fail"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class MFVC {
|
||||
// source: 'mfvcUntypedEqualsOverriden.kt'
|
||||
private final field field-0: int
|
||||
private final field field-1: int
|
||||
private synthetic method <init>(p0: int, p1: int): void
|
||||
public synthetic final static method box-impl(p0: int, p1: int): MFVC
|
||||
public final static method constructor-impl(p0: int, p1: int): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: int, p1: int, @org.jetbrains.annotations.Nullable p2: java.lang.Object): boolean
|
||||
public final static method equals-sUp7gFk(p0: int, p1: int, p2: int, p3: int): boolean
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: int, p1: int): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: int, p1: int): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): int
|
||||
public synthetic final method unbox-impl-1(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MfvcUntypedEqualsOverridenKt {
|
||||
// source: 'mfvcUntypedEqualsOverriden.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
Reference in New Issue
Block a user