diff --git a/compiler/testData/codegen/box/dataClasses/hashCode/boolean.kt b/compiler/testData/codegen/box/dataClasses/hashCode/boolean.kt index afc41bbe2e7..e231e75a57b 100644 --- a/compiler/testData/codegen/box/dataClasses/hashCode/boolean.kt +++ b/compiler/testData/codegen/box/dataClasses/hashCode/boolean.kt @@ -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" } diff --git a/js/js.libraries/src/js/core.js b/js/js.libraries/src/js/core.js index 36b202d0244..6b3e4b3bf12 100644 --- a/js/js.libraries/src/js/core.js +++ b/js/js.libraries/src/js/core.js @@ -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) {