[K/N] Mark Any?.identityHashCode() with ExperimentalNativeApi

Instead of ExperimentalStdlibApi

As a part of efforts to stabilize Native stdlib #KT-55765.
This commit is contained in:
Abduqodiri Qurbonzoda
2023-04-12 23:20:49 +03:00
committed by Space Team
parent 92ab82b2f3
commit 2140580fb1
3 changed files with 6 additions and 3 deletions
@@ -5,6 +5,7 @@
package kotlin package kotlin
import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.identityHashCode import kotlin.native.identityHashCode
import kotlin.native.internal.fullName import kotlin.native.internal.fullName
import kotlin.native.internal.ExportTypeInfo import kotlin.native.internal.ExportTypeInfo
@@ -36,7 +37,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. * * 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. * * 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) @OptIn(ExperimentalNativeApi::class)
public open fun hashCode(): Int = this.identityHashCode() public open fun hashCode(): Int = this.identityHashCode()
/** /**
@@ -4,6 +4,7 @@
*/ */
package kotlin.native package kotlin.native
import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.concurrent.InvalidMutabilityException import kotlin.native.concurrent.InvalidMutabilityException
import kotlin.native.internal.ExportForCppRuntime import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.GCUnsafeCall import kotlin.native.internal.GCUnsafeCall
@@ -114,6 +115,6 @@ public external fun terminateWithUnhandledException(throwable: Throwable): Nothi
* Compute stable wrt potential object relocations by the memory manager identity hash code. * Compute stable wrt potential object relocations by the memory manager identity hash code.
* @return 0 for `null` object, identity hash code otherwise. * @return 0 for `null` object, identity hash code otherwise.
*/ */
@ExperimentalStdlibApi @ExperimentalNativeApi
@GCUnsafeCall("Kotlin_Any_hashCode") @GCUnsafeCall("Kotlin_Any_hashCode")
public external fun Any?.identityHashCode(): Int public external fun Any?.identityHashCode(): Int
@@ -5,6 +5,7 @@
package kotlin.native.concurrent package kotlin.native.concurrent
import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.internal.DescribeObjectForDebugging import kotlin.native.internal.DescribeObjectForDebugging
import kotlin.native.internal.ExportForCppRuntime import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.GCUnsafeCall import kotlin.native.internal.GCUnsafeCall
@@ -130,7 +131,7 @@ internal fun ThrowFreezingException(toFreeze: Any, blocker: Any): Nothing =
@ExportForCppRuntime @ExportForCppRuntime
@FreezingIsDeprecated @FreezingIsDeprecated
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalNativeApi::class)
internal fun ThrowInvalidMutabilityException(where: Any): Nothing { internal fun ThrowInvalidMutabilityException(where: Any): Nothing {
val description = debugDescription(where::class, where.identityHashCode()) val description = debugDescription(where::class, where.identityHashCode())
throw InvalidMutabilityException("mutation attempt of frozen $description") throw InvalidMutabilityException("mutation attempt of frozen $description")