Skip to content

Commit 6b2e90b

Browse files
committed
Suppress cancel(cause) related warnings in internal implementation
1 parent 3179683 commit 6b2e90b

File tree

9 files changed

+16
-6
lines changed

9 files changed

+16
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public fun handleCoroutineException(context: CoroutineContext, exception: Throwa
2626
if (exception is CancellationException) return // nothing to do
2727
// Try propagate exception to parent
2828
val job = context[Job]
29+
@Suppress("DEPRECATION")
2930
if (job !== null && job !== caller && job.cancel(exception)) return // handle by parent
3031
// otherwise -- use exception handlers
3132
handleExceptionViaHandler(context, exception)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public interface Job : CoroutineContext.Element {
157157
/**
158158
* @suppress
159159
*/
160-
@Suppress("INAPPLICABLE_JVM_NAME")
160+
@Suppress("INAPPLICABLE_JVM_NAME", "DEPRECATION")
161161
@Deprecated(level = DeprecationLevel.HIDDEN, message = "Left here for binary compatibility")
162162
@JvmName("cancel")
163163
public fun cancel0(): Boolean = cancel(null)
@@ -473,6 +473,7 @@ public suspend fun Job.cancelAndJoin() {
473473
@ObsoleteCoroutinesApi
474474
@Deprecated(level = DeprecationLevel.WARNING, message = "Use cancelChildren() without cause", replaceWith = ReplaceWith("cancelChildren()"))
475475
public fun Job.cancelChildren(cause: Throwable? = null) {
476+
@Suppress("DEPRECATION")
476477
children.forEach { it.cancel(cause) }
477478
}
478479

@@ -509,6 +510,7 @@ public val CoroutineContext.isActive: Boolean
509510
/**
510511
* @suppress
511512
*/
513+
@Suppress("unused")
512514
@JvmName("cancel")
513515
@Deprecated(message = "Binary compatibility", level = DeprecationLevel.HIDDEN)
514516
public fun CoroutineContext.cancel0(): Boolean {
@@ -529,6 +531,7 @@ public fun CoroutineContext.cancel(): Unit {
529531
@ObsoleteCoroutinesApi
530532
@Deprecated(level = DeprecationLevel.WARNING, message = "Use cancel() without cause", replaceWith = ReplaceWith("cancel()"))
531533
public fun CoroutineContext.cancel(cause: Throwable? = null): Boolean =
534+
@Suppress("DEPRECATION")
532535
this[Job]?.cancel(cause) ?: false
533536

534537
/**
@@ -542,6 +545,7 @@ public fun CoroutineContext.cancelChildren() {
542545
@ObsoleteCoroutinesApi
543546
@Deprecated(level = DeprecationLevel.WARNING, message = "Use cancelChildren() without cause", replaceWith = ReplaceWith("cancelChildren()"))
544547
public fun CoroutineContext.cancelChildren(cause: Throwable? = null) {
548+
@Suppress("DEPRECATION")
545549
this[Job]?.children?.forEach { it.cancel(cause) }
546550
}
547551

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ public open class JobSupport constructor(active: Boolean) : Job, ChildJob, Paren
559559
internal open val onCancelComplete: Boolean get() = false
560560

561561
// external cancel without cause, never invoked implicitly from internal machinery
562-
public override fun cancel(): Unit {
562+
public override fun cancel() {
563+
@Suppress("DEPRECATION")
563564
cancel(null) // must delegate here, because some classes override cancel(x)
564565
}
565566

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private open class TimeoutCoroutine<U, in T: U>(
8383
) : AbstractCoroutine<T>(uCont.context, active = true), Runnable, Continuation<T> {
8484
override val defaultResumeMode: Int get() = MODE_DIRECT
8585

86-
@Suppress("LeakingThis")
86+
@Suppress("LeakingThis", "Deprecation")
8787
override fun run() {
8888
cancel(TimeoutCancellationException(time, this))
8989
}

common/kotlinx-coroutines-core-common/src/channels/AbstractChannel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ internal abstract class AbstractChannel<E> : AbstractSendChannel<E>(), Channel<E
657657
return if (result === POLL_FAILED) null else receiveOrNullResult(result)
658658
}
659659

660-
override fun cancel(): Unit {
660+
override fun cancel() {
661+
@Suppress("DEPRECATION")
661662
cancel(null)
662663
}
663664

common/kotlinx-coroutines-core-common/src/channels/ArrayBroadcastChannel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ internal class ArrayBroadcastChannel<E>(
6969

7070
public override fun cancel(cause: Throwable?): Boolean =
7171
close(cause).also {
72+
@Suppress("DEPRECATION")
7273
for (sub in subscribers) sub.cancel(cause)
7374
}
7475

common/kotlinx-coroutines-core-common/src/channels/Broadcast.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ private open class BroadcastCoroutine<E>(
9292

9393
override fun cancel(cause: Throwable?): Boolean {
9494
val wasCancelled = _channel.cancel(cause)
95+
@Suppress("DEPRECATION")
9596
if (wasCancelled) super.cancel(cause) // cancel the job
9697
return wasCancelled
9798
}

common/kotlinx-coroutines-core-common/src/channels/Channel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public interface ReceiveChannel<out E> {
255255
/**
256256
* @suppress
257257
*/
258-
@Suppress("INAPPLICABLE_JVM_NAME")
258+
@Suppress("INAPPLICABLE_JVM_NAME", "DEPRECATION")
259259
@Deprecated(level = DeprecationLevel.HIDDEN, message = "Left here for binary compatibility")
260260
@JvmName("cancel")
261261
public fun cancel0(): Boolean = cancel(null)

common/kotlinx-coroutines-core-common/src/channels/ChannelCoroutine.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package kotlinx.coroutines.channels
77
import kotlinx.coroutines.*
88
import kotlin.coroutines.*
99

10+
@Suppress("DEPRECATION")
1011
internal open class ChannelCoroutine<E>(
1112
parentContext: CoroutineContext,
1213
protected val _channel: Channel<E>,
@@ -16,7 +17,7 @@ internal open class ChannelCoroutine<E>(
1617

1718
val channel: Channel<E> get() = this
1819

19-
override fun cancel(): Unit {
20+
override fun cancel() {
2021
cancel(null)
2122
}
2223

0 commit comments

Comments
 (0)