Align the Boolean.hashCode() value across platforms
Boolean.hashCode() should return 1231/1237 for true/false correspondingly. As a part of efforts to stabilize Native stdlib.
This commit is contained in:
committed by
Space Team
parent
668157eb41
commit
193aa0f935
@@ -48,11 +48,15 @@ internal fun hashCode(obj: dynamic): Int {
|
||||
"object" -> if ("function" === jsTypeOf(obj.hashCode)) (obj.hashCode)() else getObjectHashCode(obj)
|
||||
"function" -> getObjectHashCode(obj)
|
||||
"number" -> getNumberHashCode(obj)
|
||||
"boolean" -> if(obj.unsafeCast<Boolean>()) 1 else 0
|
||||
"boolean" -> getBooleanHashCode(obj.unsafeCast<Boolean>())
|
||||
else -> getStringHashCode(js("String")(obj))
|
||||
}
|
||||
}
|
||||
|
||||
internal fun getBooleanHashCode(value: Boolean): Int {
|
||||
return if (value) 1231 else 1237
|
||||
}
|
||||
|
||||
private const val POW_2_32 = 4294967296.0
|
||||
private const val OBJECT_HASH_CODE_PROPERTY_NAME = "kotlinHashCodeValue$"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user