From 596cbdfb71136de5ee66d5491748dd05a4f8e124 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Tue, 7 Sep 2021 19:36:07 +0300 Subject: [PATCH] [TESTS] Remove jvm specific annotations from coroutine helpers --- .../helpers/coroutines/CoroutineHelpers.kt | 4 ---- .../helpers/coroutines/CoroutineUtil.kt | 21 +++++++++++++++++++ .../helpers/coroutines/StateMachineChecker.kt | 21 ------------------- .../coroutines/TailCallOptimizationChecker.kt | 3 --- .../CoroutineHelpersSourceFilesProvider.kt | 2 ++ 5 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 compiler/testData/diagnostics/helpers/coroutines/CoroutineUtil.kt diff --git a/compiler/testData/diagnostics/helpers/coroutines/CoroutineHelpers.kt b/compiler/testData/diagnostics/helpers/coroutines/CoroutineHelpers.kt index 6d72aea84dd..a47f74926dc 100644 --- a/compiler/testData/diagnostics/helpers/coroutines/CoroutineHelpers.kt +++ b/compiler/testData/diagnostics/helpers/coroutines/CoroutineHelpers.kt @@ -1,11 +1,7 @@ -@file:JvmMultifileClass -@file:JvmName("CoroutineUtilKt") - package helpers import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* -import kotlin.coroutines.jvm.internal.* fun handleResultContinuation(x: (T) -> Unit): Continuation = object: Continuation { override val context = EmptyCoroutineContext diff --git a/compiler/testData/diagnostics/helpers/coroutines/CoroutineUtil.kt b/compiler/testData/diagnostics/helpers/coroutines/CoroutineUtil.kt new file mode 100644 index 00000000000..e9f88bde7f3 --- /dev/null +++ b/compiler/testData/diagnostics/helpers/coroutines/CoroutineUtil.kt @@ -0,0 +1,21 @@ +package helpers + +import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* + +val StateMachineChecker = StateMachineCheckerClass() + +object CheckStateMachineContinuation: ContinuationAdapter() { + override val context: CoroutineContext + get() = EmptyCoroutineContext + + override fun resume(value: Unit) { + StateMachineChecker.proceed = { + StateMachineChecker.finished = true + } + } + + override fun resumeWithException(exception: Throwable) { + throw exception + } +} diff --git a/compiler/testData/diagnostics/helpers/coroutines/StateMachineChecker.kt b/compiler/testData/diagnostics/helpers/coroutines/StateMachineChecker.kt index bd4ab066365..dc2c32000d6 100644 --- a/compiler/testData/diagnostics/helpers/coroutines/StateMachineChecker.kt +++ b/compiler/testData/diagnostics/helpers/coroutines/StateMachineChecker.kt @@ -1,11 +1,7 @@ -@file:JvmMultifileClass -@file:JvmName("CoroutineUtilKt") - package helpers import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* -import kotlin.coroutines.jvm.internal.* class StateMachineCheckerClass { private var counter = 0 @@ -36,20 +32,3 @@ class StateMachineCheckerClass { if (checkFinished && !finished) error("Wrong state-machine generated: it is not finished yet") } } - -val StateMachineChecker = StateMachineCheckerClass() - -object CheckStateMachineContinuation: ContinuationAdapter() { - override val context: CoroutineContext - get() = EmptyCoroutineContext - - override fun resume(value: Unit) { - StateMachineChecker.proceed = { - StateMachineChecker.finished = true - } - } - - override fun resumeWithException(exception: Throwable) { - throw exception - } -} diff --git a/compiler/testData/diagnostics/helpers/coroutines/TailCallOptimizationChecker.kt b/compiler/testData/diagnostics/helpers/coroutines/TailCallOptimizationChecker.kt index e81cd4e907f..ad89c2c337c 100644 --- a/compiler/testData/diagnostics/helpers/coroutines/TailCallOptimizationChecker.kt +++ b/compiler/testData/diagnostics/helpers/coroutines/TailCallOptimizationChecker.kt @@ -1,6 +1,3 @@ -@file:JvmMultifileClass -@file:JvmName("CoroutineUtilKt") - package helpers import kotlin.coroutines.* diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt index efede5e9a38..cdd121ab86d 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/CoroutineHelpersSourceFilesProvider.kt @@ -21,6 +21,7 @@ class CoroutineHelpersSourceFilesProvider(testServices: TestServices, testDataPa private val helpersPath = "$testDataPath/compiler/testData/diagnostics/helpers/coroutines" private val coroutineHelpersPath = "$helpersPath/CoroutineHelpers.kt" + private val coroutineUtilPath = "$helpersPath/CoroutineUtil.kt" private val stateMachineCheckerPath = "$helpersPath/StateMachineChecker.kt" private val tailCallOptimizationCheckerPath = "$helpersPath/TailCallOptimizationChecker.kt" @@ -33,6 +34,7 @@ class CoroutineHelpersSourceFilesProvider(testServices: TestServices, testDataPa return buildList { add(File(coroutineHelpersPath).toTestFile()) if (CHECK_STATE_MACHINE in module.directives) { + add(File(coroutineUtilPath).toTestFile()) add(File(stateMachineCheckerPath).toTestFile()) } if (CHECK_TAIL_CALL_OPTIMIZATION in module.directives) {