From 72f87ba55fc55f83d72334dd5ed24dddbb40f0c0 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Thu, 6 Apr 2023 20:45:53 +0300 Subject: [PATCH] [K/N] Internalize functions for throwing specific exception from C++ code As a part of efforts to stabilize Native stdlib. --- .../kotlin/native/internal/RuntimeUtils.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt index 2022a758836..6795354dfe7 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt @@ -11,7 +11,8 @@ import kotlin.native.concurrent.FreezableAtomicReference import kotlin.native.concurrent.freeze @ExportForCppRuntime -fun ThrowNullPointerException(): Nothing { +@PublishedApi +internal fun ThrowNullPointerException(): Nothing { throw NullPointerException() } @@ -26,23 +27,27 @@ internal fun ThrowArrayIndexOutOfBoundsException(): Nothing { } @ExportForCppRuntime -fun ThrowClassCastException(instance: Any, typeInfo: NativePtr): Nothing { +@PublishedApi +internal fun ThrowClassCastException(instance: Any, typeInfo: NativePtr): Nothing { val clazz = KClassImpl(typeInfo) throw ClassCastException("${instance::class} cannot be cast to $clazz") } @ExportForCppRuntime -fun ThrowTypeCastException(instance: Any, typeName: String): Nothing { +@PublishedApi +internal fun ThrowTypeCastException(instance: Any, typeName: String): Nothing { throw TypeCastException("${instance::class} cannot be cast to class $typeName") } @ExportForCppRuntime -fun ThrowKotlinNothingValueException(): Nothing { +@PublishedApi +internal fun ThrowKotlinNothingValueException(): Nothing { throw KotlinNothingValueException() } @ExportForCppRuntime -fun ThrowInvalidReceiverTypeException(klass: KClass<*>): Nothing { +@PublishedApi +internal fun ThrowInvalidReceiverTypeException(klass: KClass<*>): Nothing { throw RuntimeException("Unexpected receiver type: " + (klass.qualifiedName ?: "noname")) } @@ -61,11 +66,13 @@ internal fun ThrowOutOfMemoryError() : Nothing { throw OutOfMemoryError() } -fun ThrowNoWhenBranchMatchedException(): Nothing { +@PublishedApi +internal fun ThrowNoWhenBranchMatchedException(): Nothing { throw NoWhenBranchMatchedException() } -fun ThrowUninitializedPropertyAccessException(propertyName: String): Nothing { +@PublishedApi +internal fun ThrowUninitializedPropertyAccessException(propertyName: String): Nothing { throw UninitializedPropertyAccessException("lateinit property $propertyName has not been initialized") }