KJS: check hashCode property only for objects to avoid extra boxing for primitive values
Also in Nashorn everything has hashCode including primitive types, so the result can be different at Nashorn and at other engines.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
data class A(val a: Boolean)
|
||||
|
||||
fun box() : String {
|
||||
return if( A(true).hashCode()==1 && A(false).hashCode()==0 ) "OK" else "fail"
|
||||
if (A(true).hashCode() != 1) return "fail1"
|
||||
if (A(false).hashCode() !=0) return "fail2"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ Kotlin.hashCode = function (obj) {
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
if ("function" === typeof obj.hashCode) {
|
||||
return obj.hashCode();
|
||||
}
|
||||
var objType = typeof obj;
|
||||
if ("object" === objType || "function" === objType) {
|
||||
if ("object" === objType) {
|
||||
return "function" === typeof obj.hashCode ? obj.hashCode() : getObjectHashCode(obj);
|
||||
}
|
||||
if ("function" === objType) {
|
||||
return getObjectHashCode(obj);
|
||||
}
|
||||
else if ("number" === objType) {
|
||||
if ("number" === objType) {
|
||||
return numberHashCode(obj);
|
||||
}
|
||||
if ("boolean" === objType) {
|
||||
|
||||
Reference in New Issue
Block a user