[WASM] Fix invalid equals/hashCode for Double.NaN and Float.NaN
This commit is contained in:
@@ -1543,8 +1543,8 @@ public class Float private constructor(public val value: Float) : Number(), Comp
|
|||||||
if (this > other) return 1
|
if (this > other) return 1
|
||||||
if (this < other) return -1
|
if (this < other) return -1
|
||||||
|
|
||||||
val thisBits = this.bits()
|
val thisBits = this.toBits()
|
||||||
val otherBits = other.bits()
|
val otherBits = other.toBits()
|
||||||
|
|
||||||
// Canonical NaN bits representation higher than any other value
|
// Canonical NaN bits representation higher than any other value
|
||||||
return thisBits.compareTo(otherBits)
|
return thisBits.compareTo(otherBits)
|
||||||
@@ -1761,7 +1761,7 @@ public class Float private constructor(public val value: Float) : Number(), Comp
|
|||||||
wasm_f64_promote_f32(this)
|
wasm_f64_promote_f32(this)
|
||||||
|
|
||||||
public inline fun equals(other: Float): Boolean =
|
public inline fun equals(other: Float): Boolean =
|
||||||
bits() == other.bits()
|
toBits() == other.toBits()
|
||||||
|
|
||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Float && this.equals(other)
|
other is Float && this.equals(other)
|
||||||
@@ -1770,11 +1770,7 @@ public class Float private constructor(public val value: Float) : Number(), Comp
|
|||||||
dtoa(this.toDouble())
|
dtoa(this.toDouble())
|
||||||
|
|
||||||
public override inline fun hashCode(): Int =
|
public override inline fun hashCode(): Int =
|
||||||
bits()
|
toBits()
|
||||||
|
|
||||||
@PublishedApi
|
|
||||||
@WasmOp(WasmOp.I32_REINTERPRET_F32)
|
|
||||||
internal fun bits(): Int = implementedAsIntrinsic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1870,8 +1866,8 @@ public class Double private constructor(public val value: Double) : Number(), Co
|
|||||||
if (this > other) return 1
|
if (this > other) return 1
|
||||||
if (this < other) return -1
|
if (this < other) return -1
|
||||||
|
|
||||||
val thisBits = this.bits()
|
val thisBits = this.toBits()
|
||||||
val otherBits = other.bits()
|
val otherBits = other.toBits()
|
||||||
|
|
||||||
// Canonical NaN bits representation higher than any other value
|
// Canonical NaN bits representation higher than any other value
|
||||||
return thisBits.compareTo(otherBits)
|
return thisBits.compareTo(otherBits)
|
||||||
@@ -2084,18 +2080,13 @@ public class Double private constructor(public val value: Double) : Number(), Co
|
|||||||
this
|
this
|
||||||
|
|
||||||
public inline fun equals(other: Double): Boolean =
|
public inline fun equals(other: Double): Boolean =
|
||||||
this.bits() == other.bits()
|
this.toBits() == other.toBits()
|
||||||
|
|
||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Double && this.bits() == other.bits()
|
other is Double && this.toBits() == other.toBits()
|
||||||
|
|
||||||
public override fun toString(): String =
|
public override fun toString(): String =
|
||||||
dtoa(this)
|
dtoa(this)
|
||||||
|
|
||||||
public override inline fun hashCode(): Int = bits().hashCode()
|
public override inline fun hashCode(): Int = toBits().hashCode()
|
||||||
|
|
||||||
@PublishedApi
|
|
||||||
@WasmOp(WasmOp.I64_REINTERPRET_F64)
|
|
||||||
internal fun bits(): Long =
|
|
||||||
implementedAsIntrinsic
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user