[Wasm, stdlib] extract Any::identityHashCode to workaround the bug in FunctionDescriptorFactory
A fix is on its way -- KT-MR-9426.
This commit is contained in:
@@ -44,15 +44,6 @@ public open class Any @WasmPrimitiveConstructor constructor() {
|
|||||||
return identityHashCode()
|
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.
|
* Returns a string representation of the object.
|
||||||
*/
|
*/
|
||||||
@@ -64,3 +55,12 @@ public open class Any @WasmPrimitiveConstructor constructor() {
|
|||||||
return "$qualifiedName@${identityHashCode()}"
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user