diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Any.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Any.kt index d25340fa004..4a36722add0 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Any.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Any.kt @@ -36,6 +36,7 @@ public open class Any { * * Whenever it is invoked on the same object more than once, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. * * If two objects are equal according to the `equals()` method, then calling the `hashCode` method on each of the two objects must produce the same integer result. */ + @OptIn(ExperimentalStdlibApi::class) public open fun hashCode(): Int = this.identityHashCode() /** diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt index 38b7134c380..81005e2e5b3 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt @@ -111,5 +111,6 @@ public external fun terminateWithUnhandledException(throwable: Throwable): Nothi * Compute stable wrt potential object relocations by the memory manager identity hash code. * @return 0 for `null` object, identity hash code otherwise. */ +@ExperimentalStdlibApi @GCUnsafeCall("Kotlin_Any_hashCode") public external fun Any?.identityHashCode(): Int diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt index 1c1c43c5f64..bfb386506bc 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt @@ -109,6 +109,7 @@ internal fun ThrowFreezingException(toFreeze: Any, blocker: Any): Nothing = @ExportForCppRuntime @FreezingIsDeprecated +@OptIn(ExperimentalStdlibApi::class) internal fun ThrowInvalidMutabilityException(where: Any): Nothing { val description = debugDescription(where::class, where.identityHashCode()) throw InvalidMutabilityException("mutation attempt of frozen $description")