Skip to content

Commit eb8fc3f

Browse files
committed
Remove CompletedExceptionally#exception
1 parent acaf77a commit eb8fc3f

File tree

7 files changed

+10
-19
lines changed

7 files changed

+10
-19
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ internal abstract class AbstractContinuation<in T>(
7575
if (trySuspend()) return COROUTINE_SUSPENDED
7676
// otherwise, onCompletionInternal was already invoked & invoked tryResume, and the result is in the state
7777
val state = this.state
78-
if (state is CompletedExceptionally) throw state.exception
78+
if (state is CompletedExceptionally) throw state.cause
7979
return getSuccessfulResult(state)
8080
}
8181

@@ -99,8 +99,8 @@ internal abstract class AbstractContinuation<in T>(
9999
}
100100
is Cancelled -> {
101101
// Ignore resumes in cancelled coroutines, but handle exception if a different one here
102-
if (proposedUpdate is CompletedExceptionally && proposedUpdate.exception != state.exception)
103-
handleException(proposedUpdate.exception)
102+
if (proposedUpdate is CompletedExceptionally && proposedUpdate.cause != state.cause)
103+
handleException(proposedUpdate.cause)
104104
return
105105
}
106106
else -> error("Already resumed, but got $proposedUpdate")

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private open class StandaloneCoroutine(
171171
override fun hasOnFinishingHandler(update: Any?) = update is CompletedExceptionally
172172
override fun onFinishingInternal(update: Any?) {
173173
// note the use of the parent's job context below!
174-
if (update is CompletedExceptionally) handleCoroutineException(parentContext, update.exception)
174+
if (update is CompletedExceptionally) handleCoroutineException(parentContext, update.cause)
175175
}
176176
}
177177

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,7 @@ package kotlinx.coroutines.experimental
2626
* or artificial JobCancellationException if no cause was provided
2727
* @suppress **This is unstable API and it is subject to change.**
2828
*/
29-
open class CompletedExceptionally(
30-
public val cause: Throwable
31-
) {
32-
/**
33-
* Returns completion exception.
34-
*/
35-
@Deprecated("Use `cause`", replaceWith = ReplaceWith("cause"))
36-
// todo: Remove exception usages
37-
public val exception: Throwable get() = cause // alias for backward compatibility
38-
29+
open class CompletedExceptionally(public val cause: Throwable) {
3930
override fun toString(): String = "$classSimpleName[$cause]"
4031
}
4132

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public interface DispatchedTask<in T> : Runnable {
142142
state as T
143143

144144
public fun getExceptionalResult(state: Any?): Throwable? =
145-
(state as? CompletedExceptionally)?.exception
145+
(state as? CompletedExceptionally)?.cause
146146

147147
public override fun run() {
148148
try {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private open class TimeoutCoroutine<U, in T: U>(
103103
@Suppress("UNCHECKED_CAST")
104104
internal override fun onCompletionInternal(state: Any?, mode: Int) {
105105
if (state is CompletedExceptionally)
106-
cont.resumeWithExceptionMode(state.exception, mode)
106+
cont.resumeWithExceptionMode(state.cause, mode)
107107
else
108108
cont.resumeMode(state as T, mode)
109109
}
@@ -173,7 +173,7 @@ private class TimeoutOrNullCoroutine<T>(
173173
@Suppress("UNCHECKED_CAST")
174174
internal override fun onCompletionInternal(state: Any?, mode: Int) {
175175
if (state is CompletedExceptionally) {
176-
val exception = state.exception
176+
val exception = state.cause
177177
if (exception is TimeoutCancellationException && exception.coroutine === this)
178178
cont.resumeMode(null, mode) else
179179
cont.resumeWithExceptionMode(exception, mode)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private inline fun <T> AbstractCoroutine<T>.undispatchedResult(startBlock: () ->
8585
return when {
8686
result === COROUTINE_SUSPENDED -> COROUTINE_SUSPENDED
8787
makeCompletingOnce(result, MODE_IGNORE) -> {
88-
if (result is CompletedExceptionally) throw result.exception else result
88+
if (result is CompletedExceptionally) throw result.cause else result
8989
}
9090
else -> COROUTINE_SUSPENDED
9191
}

core/kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Builders.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private class BlockingCoroutine<T>(
9494
timeSource.unregisterTimeLoopThread()
9595
// now return result
9696
val state = this.state
97-
(state as? CompletedExceptionally)?.let { throw it.exception }
97+
(state as? CompletedExceptionally)?.let { throw it.cause }
9898
return state as T
9999
}
100100
}

0 commit comments

Comments
 (0)