Skip to content

Commit bb19a26

Browse files
qwwdfsadelizarov
authored andcommitted
Add default parameters to deprecated CancellableContinuation#invokeOnCompletion for smoother migration
1 parent f2b4e0e commit bb19a26

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-core.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public abstract interface class kotlinx/coroutines/experimental/CancellableConti
4444
public abstract fun completeResume (Ljava/lang/Object;)V
4545
public abstract fun initCancellability ()V
4646
public abstract fun invokeOnCancellation (Lkotlin/jvm/functions/Function1;)V
47-
public abstract synthetic fun invokeOnCompletion (Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
47+
public abstract synthetic fun invokeOnCompletion (ZZLkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
4848
public abstract fun isActive ()Z
4949
public abstract fun isCancelled ()Z
5050
public abstract fun isCompleted ()Z
@@ -56,6 +56,7 @@ public abstract interface class kotlinx/coroutines/experimental/CancellableConti
5656

5757
public final class kotlinx/coroutines/experimental/CancellableContinuation$DefaultImpls {
5858
public static synthetic fun cancel$default (Lkotlinx/coroutines/experimental/CancellableContinuation;Ljava/lang/Throwable;ILjava/lang/Object;)Z
59+
public static synthetic fun invokeOnCompletion$default (Lkotlinx/coroutines/experimental/CancellableContinuation;ZZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/coroutines/experimental/DisposableHandle;
5960
public static synthetic fun tryResume$default (Lkotlinx/coroutines/experimental/CancellableContinuation;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;
6061
}
6162

@@ -65,7 +66,7 @@ public final class kotlinx/coroutines/experimental/CancellableContinuationImpl :
6566
public fun getContext ()Lkotlin/coroutines/experimental/CoroutineContext;
6667
public fun getSuccessfulResult (Ljava/lang/Object;)Ljava/lang/Object;
6768
public fun initCancellability ()V
68-
public synthetic fun invokeOnCompletion (Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
69+
public synthetic fun invokeOnCompletion (ZZLkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
6970
public fun resumeUndispatched (Lkotlinx/coroutines/experimental/CoroutineDispatcher;Ljava/lang/Object;)V
7071
public fun resumeUndispatchedWithException (Lkotlinx/coroutines/experimental/CoroutineDispatcher;Ljava/lang/Throwable;)V
7172
public fun tryResume (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/CancellableContinuation.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,20 @@ public interface CancellableContinuation<in T> : Continuation<T> {
126126
* wrapped into [CompletionHandlerException], and rethrown, potentially causing the crash of unrelated code.
127127
*
128128
* At most one [handler] can be installed on one continuation
129+
*
130+
* @param invokeImmediately not used
131+
* @param onCancelling not used
132+
* @return not used
129133
*/
130134
@Deprecated(
131135
message = "Disposable handlers on regular completion are no longer supported",
132136
replaceWith = ReplaceWith("invokeOnCancellation(handler)"),
133-
level = DeprecationLevel.HIDDEN)
134-
public fun invokeOnCompletion(handler: CompletionHandler): DisposableHandle
137+
level = DeprecationLevel.HIDDEN
138+
)
139+
public fun invokeOnCompletion(
140+
onCancelling: Boolean = false,
141+
invokeImmediately: Boolean = true,
142+
handler: CompletionHandler): DisposableHandle
135143

136144
/**
137145
* Registers handler that is **synchronously** invoked once on cancellation (both regular and exceptional) of this continuation.
@@ -274,7 +282,8 @@ internal class CancellableContinuationImpl<in T>(
274282
initParentJobInternal(delegate.context[Job])
275283
}
276284

277-
override fun invokeOnCompletion(handler: CompletionHandler): DisposableHandle {
285+
override fun invokeOnCompletion(onCancelling: Boolean,
286+
invokeImmediately: Boolean, handler: CompletionHandler): DisposableHandle {
278287
invokeOnCancellation(handler)
279288
return NonDisposableHandle
280289
}

0 commit comments

Comments
 (0)