diff --git a/libraries/stdlib/wasm/builtins/kotlin/Any.kt b/libraries/stdlib/wasm/builtins/kotlin/Any.kt index ddce260de45..c7568742f60 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Any.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Any.kt @@ -44,15 +44,6 @@ public open class Any @WasmPrimitiveConstructor constructor() { return identityHashCode() } - // Don't use outside, otherwise it could break classes reusing `_hashCode` field, like String. - // Don't inline it into usages, specifically to `hashCode`. - // It was extracted to remove `toString`'s dependency on `hashCode`, which improves output size when DCE is involved. - private fun identityHashCode(): Int { - if (_hashCode == 0) - _hashCode = Random.nextInt(1, Int.MAX_VALUE) - return _hashCode - } - /** * Returns a string representation of the object. */ @@ -64,3 +55,12 @@ public open class Any @WasmPrimitiveConstructor constructor() { return "$qualifiedName@${identityHashCode()}" } } + +// Don't use outside, otherwise it could break classes reusing `_hashCode` field, like String. +// Don't inline it into usages, specifically to `hashCode`. +// It was extracted to remove `toString`'s dependency on `hashCode`, which improves output size when DCE is involved. +private fun Any.identityHashCode(): Int { + if (_hashCode == 0) + _hashCode = Random.nextInt(1, Int.MAX_VALUE) + return _hashCode +}