From 59b54753502f2f733535e202865ee87336a56421 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Thu, 29 Apr 2021 11:16:02 +0000 Subject: [PATCH] Fix WITH_COROUTINES tests compilation on Native after 5617d83c --- .../org/jetbrains/kotlin/coroutineTestUtil.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/coroutineTestUtil.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/coroutineTestUtil.kt index 93fda9e6e46..581ba57bdca 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/coroutineTestUtil.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/coroutineTestUtil.kt @@ -36,6 +36,21 @@ open class EmptyContinuation(override val context: CoroutineContext = EmptyCorou } } +abstract class ContinuationAdapter : Continuation { + override val context: CoroutineContext = EmptyCoroutineContext + + override fun resumeWith(result: Result) { + if (result.isSuccess) { + resume(result.getOrThrow()) + } else { + resumeWithException(result.exceptionOrNull()!!) + } + } + + abstract fun resumeWithException(exception: Throwable) + abstract fun resume(value: T) +} + class StateMachineCheckerClass { private var counter = 0 var finished = false @@ -66,7 +81,7 @@ class StateMachineCheckerClass { } } val StateMachineChecker = StateMachineCheckerClass() -object CheckStateMachineContinuation: Continuation() { +object CheckStateMachineContinuation: Continuation { override val context: CoroutineContext get() = EmptyCoroutineContext