Skip to content

Commit 7659d65

Browse files
authored
Introduce workaround (in fact, fix the previously incorrect expect-actual mapping) for CancellationException. (#3850)
See KT-61168 & KT-22004 for the future solution
1 parent 84a2cba commit 7659d65

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

kotlinx-coroutines-core/common/src/Exceptions.common.kt

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class CompletionHandlerException(message: String, cause: Throwable) : Run
1414

1515
public expect open class CancellationException(message: String?) : IllegalStateException
1616

17-
@Suppress("FunctionName", "NO_ACTUAL_FOR_EXPECT")
1817
public expect fun CancellationException(message: String?, cause: Throwable?) : CancellationException
1918

2019
internal expect class JobCancellationException(

kotlinx-coroutines-core/js/src/Exceptions.kt

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ package kotlinx.coroutines
1212
*/
1313
public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException
1414

15+
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
16+
@kotlin.internal.LowPriorityInOverloadResolution
17+
public actual fun CancellationException(message: String?, cause: Throwable?): CancellationException =
18+
CancellationException(message, cause)
19+
1520
/**
1621
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed
1722
* without cause, or with a cause or exception that is not [CancellationException]

kotlinx-coroutines-core/jvm/src/Exceptions.kt

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public actual typealias CancellationException = java.util.concurrent.Cancellatio
1717
/**
1818
* Creates a cancellation exception with a specified message and [cause].
1919
*/
20-
@Suppress("FunctionName")
2120
public actual fun CancellationException(message: String?, cause: Throwable?) : CancellationException =
2221
CancellationException(message).apply { initCause(cause) }
2322

kotlinx-coroutines-core/native/src/Exceptions.kt

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import kotlinx.coroutines.internal.SuppressSupportingThrowableImpl
1515
*/
1616
public actual typealias CancellationException = kotlin.coroutines.cancellation.CancellationException
1717

18+
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
19+
@kotlin.internal.LowPriorityInOverloadResolution
20+
public actual fun CancellationException(message: String?, cause: Throwable?): CancellationException =
21+
CancellationException(message, cause)
22+
1823
/**
1924
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled or completed
2025
* without cause, or with a cause or exception that is not [CancellationException]

0 commit comments

Comments
 (0)