diff --git a/generators/builtins/primitives/NativePrimitivesGenerator.kt b/generators/builtins/primitives/NativePrimitivesGenerator.kt index a7bc4139151..c568af04ced 100644 --- a/generators/builtins/primitives/NativePrimitivesGenerator.kt +++ b/generators/builtins/primitives/NativePrimitivesGenerator.kt @@ -161,7 +161,7 @@ class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(w override fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) { val additionalCheck = if (thisKind in PrimitiveType.floatingPoint) { - "this.equals(other)" + "toBits() == other.toBits()" } else { "kotlin.native.internal.areEqualByValue(this, $parameterName)" } @@ -212,6 +212,7 @@ class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(w private fun ClassBuilder.generateCustomEquals(thisKind: PrimitiveType) { method { + annotations += "Deprecated(\"Provided for binary compatibility\", level = DeprecationLevel.HIDDEN)" annotations += "kotlin.internal.IntrinsicConstEvaluation" signature { methodName = "equals" diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Boolean.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Boolean.kt index c395f9fee39..267b4d51b49 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Boolean.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Boolean.kt @@ -51,6 +51,7 @@ public class Boolean private constructor() : Comparable { @kotlin.internal.IntrinsicConstEvaluation external public override fun compareTo(other: Boolean): Int + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Boolean): Boolean = kotlin.native.internal.areEqualByValue(this, other) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt index 62a7a8c0bd0..ade51a6e5d9 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt @@ -204,12 +204,13 @@ public class Char private constructor() : Comparable { public const val MAX_RADIX: Int = 36 } + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Char): Boolean = this == other @kotlin.internal.IntrinsicConstEvaluation public override fun equals(other: Any?): Boolean = - other is Char && this.equals(other) + other is Char && this.code == other.code @GCUnsafeCall("Kotlin_Char_toString") @kotlin.internal.IntrinsicConstEvaluation diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt index c781745307f..61c7013a21e 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt @@ -435,6 +435,7 @@ public final class Byte private constructor() : Number(), Comparable { public override fun equals(other: Any?): Boolean = other is Byte && kotlin.native.internal.areEqualByValue(this, other) + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Byte): Boolean = kotlin.native.internal.areEqualByValue(this, other) @@ -863,6 +864,7 @@ public final class Short private constructor() : Number(), Comparable { public override fun equals(other: Any?): Boolean = other is Short && kotlin.native.internal.areEqualByValue(this, other) + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Short): Boolean = kotlin.native.internal.areEqualByValue(this, other) @@ -1344,6 +1346,7 @@ public final class Int private constructor() : Number(), Comparable { public override fun equals(other: Any?): Boolean = other is Int && kotlin.native.internal.areEqualByValue(this, other) + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Int): Boolean = kotlin.native.internal.areEqualByValue(this, other) @@ -1828,6 +1831,7 @@ public final class Long private constructor() : Number(), Comparable { public override fun equals(other: Any?): Boolean = other is Long && kotlin.native.internal.areEqualByValue(this, other) + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Long): Boolean = kotlin.native.internal.areEqualByValue(this, other) @@ -2226,8 +2230,9 @@ public final class Float private constructor() : Number(), Comparable { @kotlin.internal.IntrinsicConstEvaluation public override fun equals(other: Any?): Boolean = - other is Float && this.equals(other) + other is Float && toBits() == other.toBits() + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Float): Boolean = toBits() == other.toBits() @@ -2632,8 +2637,9 @@ public final class Double private constructor() : Number(), Comparable { @kotlin.internal.IntrinsicConstEvaluation public override fun equals(other: Any?): Boolean = - other is Double && this.equals(other) + other is Double && toBits() == other.toBits() + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Double): Boolean = toBits() == other.toBits() diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt index 95dc47202a4..866d8e4c2a5 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/simd.kt @@ -37,12 +37,13 @@ public final class Vector128 private constructor() { public override fun toString() = "(0x${getUIntAt(0).toString(16)}, 0x${getUIntAt(1).toString(16)}, 0x${getUIntAt(2).toString(16)}, 0x${getUIntAt(3).toString(16)})" - // Not as good for floating types + @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) public fun equals(other: Vector128): Boolean = getLongAt(0) == other.getLongAt(0) && getLongAt(1) == other.getLongAt(1) + // Not as good for floating types public override fun equals(other: Any?): Boolean = - other is Vector128 && this.equals(other) + other is Vector128 && getLongAt(0) == other.getLongAt(0) && getLongAt(1) == other.getLongAt(1) override fun hashCode(): Int { val x0 = getLongAt(0)