[K/N] Hide Primitive.equals(Primitive) functions #KT-57344
As a part of efforts to stabilize Native stdlib. Merge-request: KT-MR-9692 Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
545a7724c1
commit
52cbad2da2
@@ -161,7 +161,7 @@ class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(w
|
|||||||
|
|
||||||
override fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) {
|
override fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) {
|
||||||
val additionalCheck = if (thisKind in PrimitiveType.floatingPoint) {
|
val additionalCheck = if (thisKind in PrimitiveType.floatingPoint) {
|
||||||
"this.equals(other)"
|
"toBits() == other.toBits()"
|
||||||
} else {
|
} else {
|
||||||
"kotlin.native.internal.areEqualByValue(this, $parameterName)"
|
"kotlin.native.internal.areEqualByValue(this, $parameterName)"
|
||||||
}
|
}
|
||||||
@@ -212,6 +212,7 @@ class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(w
|
|||||||
|
|
||||||
private fun ClassBuilder.generateCustomEquals(thisKind: PrimitiveType) {
|
private fun ClassBuilder.generateCustomEquals(thisKind: PrimitiveType) {
|
||||||
method {
|
method {
|
||||||
|
annotations += "Deprecated(\"Provided for binary compatibility\", level = DeprecationLevel.HIDDEN)"
|
||||||
annotations += "kotlin.internal.IntrinsicConstEvaluation"
|
annotations += "kotlin.internal.IntrinsicConstEvaluation"
|
||||||
signature {
|
signature {
|
||||||
methodName = "equals"
|
methodName = "equals"
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class Boolean private constructor() : Comparable<Boolean> {
|
|||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
external public override fun compareTo(other: Boolean): Int
|
external public override fun compareTo(other: Boolean): Int
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Boolean): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
public fun equals(other: Boolean): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
|
|||||||
@@ -204,12 +204,13 @@ public class Char private constructor() : Comparable<Char> {
|
|||||||
public const val MAX_RADIX: Int = 36
|
public const val MAX_RADIX: Int = 36
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Char): Boolean = this == other
|
public fun equals(other: Char): Boolean = this == other
|
||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Char && this.equals(other)
|
other is Char && this.code == other.code
|
||||||
|
|
||||||
@GCUnsafeCall("Kotlin_Char_toString")
|
@GCUnsafeCall("Kotlin_Char_toString")
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
|
|||||||
@@ -435,6 +435,7 @@ public final class Byte private constructor() : Number(), Comparable<Byte> {
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Byte && kotlin.native.internal.areEqualByValue(this, other)
|
other is Byte && kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Byte): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
public fun equals(other: Byte): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
@@ -863,6 +864,7 @@ public final class Short private constructor() : Number(), Comparable<Short> {
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Short && kotlin.native.internal.areEqualByValue(this, other)
|
other is Short && kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Short): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
public fun equals(other: Short): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
@@ -1344,6 +1346,7 @@ public final class Int private constructor() : Number(), Comparable<Int> {
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Int && kotlin.native.internal.areEqualByValue(this, other)
|
other is Int && kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Int): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
public fun equals(other: Int): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
@@ -1828,6 +1831,7 @@ public final class Long private constructor() : Number(), Comparable<Long> {
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Long && kotlin.native.internal.areEqualByValue(this, other)
|
other is Long && kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Long): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
public fun equals(other: Long): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
||||||
|
|
||||||
@@ -2226,8 +2230,9 @@ public final class Float private constructor() : Number(), Comparable<Float> {
|
|||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public override fun equals(other: Any?): Boolean =
|
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
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Float): Boolean = toBits() == other.toBits()
|
public fun equals(other: Float): Boolean = toBits() == other.toBits()
|
||||||
|
|
||||||
@@ -2632,8 +2637,9 @@ public final class Double private constructor() : Number(), Comparable<Double> {
|
|||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public override fun equals(other: Any?): Boolean =
|
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
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public fun equals(other: Double): Boolean = toBits() == other.toBits()
|
public fun equals(other: Double): Boolean = toBits() == other.toBits()
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,13 @@ public final class Vector128 private constructor() {
|
|||||||
public override fun toString() =
|
public override fun toString() =
|
||||||
"(0x${getUIntAt(0).toString(16)}, 0x${getUIntAt(1).toString(16)}, 0x${getUIntAt(2).toString(16)}, 0x${getUIntAt(3).toString(16)})"
|
"(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 =
|
public fun equals(other: Vector128): Boolean =
|
||||||
getLongAt(0) == other.getLongAt(0) && getLongAt(1) == other.getLongAt(1)
|
getLongAt(0) == other.getLongAt(0) && getLongAt(1) == other.getLongAt(1)
|
||||||
|
|
||||||
|
// Not as good for floating types
|
||||||
public override fun equals(other: Any?): Boolean =
|
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 {
|
override fun hashCode(): Int {
|
||||||
val x0 = getLongAt(0)
|
val x0 = getLongAt(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user