Add default parameters to deprecated CancellableContinuation#invokeOnCompletion for smoother migration
diff --git a/binary-compatibility-validator/reference-public-api/kotlinx-coroutines-core.txt b/binary-compatibility-validator/reference-public-api/kotlinx-coroutines-core.txt
index 40964f8..b87bd89 100644
--- a/binary-compatibility-validator/reference-public-api/kotlinx-coroutines-core.txt
+++ b/binary-compatibility-validator/reference-public-api/kotlinx-coroutines-core.txt
@@ -44,7 +44,7 @@
public abstract fun completeResume (Ljava/lang/Object;)V
public abstract fun initCancellability ()V
public abstract fun invokeOnCancellation (Lkotlin/jvm/functions/Function1;)V
- public abstract synthetic fun invokeOnCompletion (Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
+ public abstract synthetic fun invokeOnCompletion (ZZLkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
public abstract fun isActive ()Z
public abstract fun isCancelled ()Z
public abstract fun isCompleted ()Z
@@ -56,6 +56,7 @@
public final class kotlinx/coroutines/experimental/CancellableContinuation$DefaultImpls {
public static synthetic fun cancel$default (Lkotlinx/coroutines/experimental/CancellableContinuation;Ljava/lang/Throwable;ILjava/lang/Object;)Z
+ public static synthetic fun invokeOnCompletion$default (Lkotlinx/coroutines/experimental/CancellableContinuation;ZZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/coroutines/experimental/DisposableHandle;
public static synthetic fun tryResume$default (Lkotlinx/coroutines/experimental/CancellableContinuation;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;
}
@@ -65,7 +66,7 @@
public fun getContext ()Lkotlin/coroutines/experimental/CoroutineContext;
public fun getSuccessfulResult (Ljava/lang/Object;)Ljava/lang/Object;
public fun initCancellability ()V
- public synthetic fun invokeOnCompletion (Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
+ public synthetic fun invokeOnCompletion (ZZLkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/experimental/DisposableHandle;
public fun resumeUndispatched (Lkotlinx/coroutines/experimental/CoroutineDispatcher;Ljava/lang/Object;)V
public fun resumeUndispatchedWithException (Lkotlinx/coroutines/experimental/CoroutineDispatcher;Ljava/lang/Throwable;)V
public fun tryResume (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
diff --git a/common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/CancellableContinuation.kt b/common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/CancellableContinuation.kt
index 8fc4a5e..084064c 100644
--- a/common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/CancellableContinuation.kt
+++ b/common/kotlinx-coroutines-core-common/src/main/kotlin/kotlinx/coroutines/experimental/CancellableContinuation.kt
@@ -126,12 +126,20 @@
* wrapped into [CompletionHandlerException], and rethrown, potentially causing the crash of unrelated code.
*
* At most one [handler] can be installed on one continuation
+ *
+ * @param invokeImmediately not used
+ * @param onCancelling not used
+ * @return not used
*/
@Deprecated(
message = "Disposable handlers on regular completion are no longer supported",
replaceWith = ReplaceWith("invokeOnCancellation(handler)"),
- level = DeprecationLevel.HIDDEN)
- public fun invokeOnCompletion(handler: CompletionHandler): DisposableHandle
+ level = DeprecationLevel.HIDDEN
+ )
+ public fun invokeOnCompletion(
+ onCancelling: Boolean = false,
+ invokeImmediately: Boolean = true,
+ handler: CompletionHandler): DisposableHandle
/**
* Registers handler that is **synchronously** invoked once on cancellation (both regular and exceptional) of this continuation.
@@ -274,7 +282,8 @@
initParentJobInternal(delegate.context[Job])
}
- override fun invokeOnCompletion(handler: CompletionHandler): DisposableHandle {
+ override fun invokeOnCompletion(onCancelling: Boolean,
+ invokeImmediately: Boolean, handler: CompletionHandler): DisposableHandle {
invokeOnCancellation(handler)
return NonDisposableHandle
}