From fb1be9b969bfb14978397031c3f462786c64af4e Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Thu, 30 Aug 2018 17:09:06 +0300 Subject: [PATCH] Fix KT-26455 and KT-26443. (#1970) --- runtime/src/main/kotlin/kotlin/native/Compatibility.kt | 3 ++- .../src/main/kotlin/kotlin/native/concurrent/Internal.kt | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/runtime/src/main/kotlin/kotlin/native/Compatibility.kt b/runtime/src/main/kotlin/kotlin/native/Compatibility.kt index 9e6cfd4ea82..2a9185347b1 100644 --- a/runtime/src/main/kotlin/kotlin/native/Compatibility.kt +++ b/runtime/src/main/kotlin/kotlin/native/Compatibility.kt @@ -18,4 +18,5 @@ public annotation class Volatile public annotation class Synchronized @kotlin.internal.InlineOnly -public actual inline fun synchronized(@Suppress("UNUSED_PARAMETER") lock: Any, block: () -> R): R = block() \ No newline at end of file +public actual inline fun synchronized(@Suppress("UNUSED_PARAMETER") lock: Any, block: () -> R): R = + throw UnsupportedOperationException("synchronized() is unsupported") \ No newline at end of file diff --git a/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt b/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt index 4dcf63b3a74..bf682ec4e5d 100644 --- a/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt +++ b/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt @@ -68,7 +68,13 @@ internal fun ThrowFreezingException(toFreeze: Any, blocker: Any): Nothing = throw FreezingException(toFreeze, blocker) @ExportForCppRuntime -internal fun ThrowInvalidMutabilityException(where: Any): Nothing = throw InvalidMutabilityException(where) +internal fun ThrowInvalidMutabilityException(where: Any): Nothing { + val kClass = where::class + val className = kClass.qualifiedName ?: kClass.simpleName ?: "" + val unsignedHashCode = where.hashCode().toLong() and 0xffffffffL + val hashCodeStr = unsignedHashCode.toString(16) + throw InvalidMutabilityException("$className@$hashCodeStr") +} @SymbolName("Kotlin_AtomicReference_checkIfFrozen") external internal fun checkIfFrozen(ref: Any?)