From af9743709c633d925e71669f2af4868dd4eb96fd Mon Sep 17 00:00:00 2001 From: Roman Elizarov Date: Mon, 25 Jun 2018 15:15:38 +0300 Subject: [PATCH] Implement COROUTINE_SUSPENDED as a property with getter --- .../src/kotlin/coroutines/intrinsics/Intrinsics.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libraries/stdlib/coroutines/src/kotlin/coroutines/intrinsics/Intrinsics.kt b/libraries/stdlib/coroutines/src/kotlin/coroutines/intrinsics/Intrinsics.kt index 6f22b8c30b4..01a5967dc17 100644 --- a/libraries/stdlib/coroutines/src/kotlin/coroutines/intrinsics/Intrinsics.kt +++ b/libraries/stdlib/coroutines/src/kotlin/coroutines/intrinsics/Intrinsics.kt @@ -68,7 +68,14 @@ public suspend inline fun suspendCoroutineUninterceptedOrReturn(crossinline * This value is used as a return value of [suspendCoroutineOrReturn] `block` argument to state that * the execution was suspended and will not return any result immediately. */ +// It is implemented as property with getter to avoid ProGuard problem with multifile IntrinsicsKt class @SinceKotlin("1.3") -public val COROUTINE_SUSPENDED: Any = CoroutineSingletons.COROUTINE_SUSPENDED +public val COROUTINE_SUSPENDED: Any + get() = CoroutineSingletons.COROUTINE_SUSPENDED -internal enum class CoroutineSingletons { COROUTINE_SUSPENDED, UNDECIDED, RESUMED } \ No newline at end of file +// Using enum here ensures two important properties: +// 1. It makes SafeContinuation serializable with all kinds of serialization frameworks (since all of them natively support enums) +// 2. It improves debugging experience, since you clearly see toString() value of those objects and what package they come from +@SinceKotlin("1.3") +@PublishedApi // This class is Published API via serialized representation of SafeContinuation, don't rename/move +internal enum class CoroutineSingletons { COROUTINE_SUSPENDED, UNDECIDED, RESUMED }