From 2ed688b2b620d1d3f763518c6c4e98380993a9b7 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 14 Aug 2023 18:45:02 +0200 Subject: [PATCH] Introduce workaround (in fact, fix the previously incorrect expect-actual mapping) for CancellationException. See KT-61168 --- kotlinx-coroutines-core/common/src/Exceptions.common.kt | 1 - kotlinx-coroutines-core/js/src/Exceptions.kt | 5 +++++ kotlinx-coroutines-core/jvm/src/Exceptions.kt | 1 - kotlinx-coroutines-core/native/src/Exceptions.kt | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kotlinx-coroutines-core/common/src/Exceptions.common.kt b/kotlinx-coroutines-core/common/src/Exceptions.common.kt index 6d5442dfdc..27d11353e7 100644 --- a/kotlinx-coroutines-core/common/src/Exceptions.common.kt +++ b/kotlinx-coroutines-core/common/src/Exceptions.common.kt @@ -14,7 +14,6 @@ public class CompletionHandlerException(message: String, cause: Throwable) : Run public expect open class CancellationException(message: String?) : IllegalStateException -@Suppress("FunctionName", "NO_ACTUAL_FOR_EXPECT") public expect fun CancellationException(message: String?, cause: Throwable?) : CancellationException internal expect class JobCancellationException( diff --git a/kotlinx-coroutines-core/js/src/Exceptions.kt b/kotlinx-coroutines-core/js/src/Exceptions.kt index da9979b603..2295f93709 100644 --- a/kotlinx-coroutines-core/js/src/Exceptions.kt +++ b/kotlinx-coroutines-core/js/src/Exceptions.kt @@ -12,6 +12,11 @@ package kotlinx.coroutines */ public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +public actual fun CancellationException(message: String?, cause: Throwable?): CancellationException = + CancellationException(message, cause) + /** * Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed * without cause, or with a cause or exception that is not [CancellationException] diff --git a/kotlinx-coroutines-core/jvm/src/Exceptions.kt b/kotlinx-coroutines-core/jvm/src/Exceptions.kt index 48b4788cc5..9c9f5bf441 100644 --- a/kotlinx-coroutines-core/jvm/src/Exceptions.kt +++ b/kotlinx-coroutines-core/jvm/src/Exceptions.kt @@ -17,7 +17,6 @@ public actual typealias CancellationException = java.util.concurrent.Cancellatio /** * Creates a cancellation exception with a specified message and [cause]. */ -@Suppress("FunctionName") public actual fun CancellationException(message: String?, cause: Throwable?) : CancellationException = CancellationException(message).apply { initCause(cause) } diff --git a/kotlinx-coroutines-core/native/src/Exceptions.kt b/kotlinx-coroutines-core/native/src/Exceptions.kt index 1a923c40ff..f9d0f5db73 100644 --- a/kotlinx-coroutines-core/native/src/Exceptions.kt +++ b/kotlinx-coroutines-core/native/src/Exceptions.kt @@ -15,6 +15,11 @@ import kotlinx.coroutines.internal.SuppressSupportingThrowableImpl */ public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +public actual fun CancellationException(message: String?, cause: Throwable?): CancellationException = + CancellationException(message, cause) + /** * Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed * without cause, or with a cause or exception that is not [CancellationException]