From 2cb9d3a8ad263ff28153c4642a802d0e7d09205e Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 13 Jan 2017 15:43:50 +0300 Subject: [PATCH] Move coroutine intrinsics to kotlin.coroutine.intrinsics package Also rename val SUSPENDED to SUSPENDED_MARKER #KT-15698 Fixed --- .../common/commonCoroutineCodegenUtil.kt | 20 ++++++-- .../coroutines/coroutineCodegenUtil.kt | 32 ++++--------- .../kotlin/codegen/inline/InlineCodegen.java | 4 +- .../kotlin/resolve/jvm/AsmTypes.java | 2 +- .../default/kotlin-coroutines.txt | 9 ---- .../codegen/box/coroutines/asyncIterator.kt | 13 ++--- .../testData/codegen/box/coroutines/await.kt | 4 +- .../box/coroutines/beginWithException.kt | 3 +- .../beginWithExceptionNoHandleException.kt | 3 +- .../codegen/box/coroutines/coercionToUnit.kt | 5 +- .../coroutines/controlFlow/breakFinally.kt | 5 +- .../coroutines/controlFlow/breakStatement.kt | 5 +- .../controlFlow/doWhileStatement.kt | 5 +- .../box/coroutines/controlFlow/forContinue.kt | 5 +- .../coroutines/controlFlow/forStatement.kt | 5 +- .../box/coroutines/controlFlow/ifStatement.kt | 5 +- .../controlFlow/returnFromFinally.kt | 5 +- .../coroutines/controlFlow/switchLikeWhen.kt | 5 +- .../coroutines/controlFlow/throwFromCatch.kt | 9 ++-- .../controlFlow/throwInTryWithHandleResult.kt | 5 +- .../coroutines/controlFlow/whileStatement.kt | 5 +- .../controllerAccessFromInnerLambda.kt | 5 +- .../coroutines/defaultParametersInSuspend.kt | 5 +- .../codegen/box/coroutines/dispatchResume.kt | 9 ++-- .../codegen/box/coroutines/emptyClosure.kt | 5 +- .../box/coroutines/falseUnitCoercion.kt | 5 +- .../codegen/box/coroutines/generate.kt | 5 +- .../codegen/box/coroutines/handleException.kt | 9 ++-- .../coroutines/handleResultCallEmptyBody.kt | 1 + .../handleResultNonUnitExpression.kt | 5 +- .../box/coroutines/handleResultSuspended.kt | 5 +- .../codegen/box/coroutines/illegalState.kt | 5 +- .../box/coroutines/inlineSuspendFunction.kt | 5 +- .../box/coroutines/inlinedTryCatchFinally.kt | 9 ++-- .../box/coroutines/innerSuspensionCalls.kt | 5 +- .../box/coroutines/instanceOfContinuation.kt | 9 ++-- .../intLikeVarSpilling/complicatedMerge.kt | 5 +- .../intLikeVarSpilling/i2bResult.kt | 5 +- .../loadFromBooleanArray.kt | 5 +- .../intLikeVarSpilling/loadFromByteArray.kt | 5 +- .../intLikeVarSpilling/noVariableInTable.kt | 5 +- .../intLikeVarSpilling/sameIconst1ManyVars.kt | 5 +- .../intLikeVarSpilling/usedInArrayStore.kt | 5 +- .../intLikeVarSpilling/usedInMethodCall.kt | 5 +- .../intLikeVarSpilling/usedInPutfield.kt | 5 +- .../intLikeVarSpilling/usedInVarStore.kt | 5 +- .../box/coroutines/iterateOverArray.kt | 5 +- .../codegen/box/coroutines/kt12958.kt | 5 +- .../box/coroutines/lastExpressionIsLoop.kt | 5 +- .../box/coroutines/lastStatementInc.kt | 5 +- .../box/coroutines/lastStementAssignment.kt | 5 +- .../box/coroutines/lastUnitExpression.kt | 5 +- .../inlineFunctionWithOptionalParam.kt | 1 + .../box/coroutines/multiModule/simple.kt | 6 ++- .../box/coroutines/multipleInvokeCalls.kt | 5 +- .../multipleInvokeCallsInsideInlineLambda1.kt | 5 +- .../multipleInvokeCallsInsideInlineLambda2.kt | 5 +- .../multipleInvokeCallsInsideInlineLambda3.kt | 5 +- .../codegen/box/coroutines/nestedTryCatch.kt | 9 ++-- .../box/coroutines/noSuspensionPoints.kt | 1 + .../nonLocalReturnFromInlineLambda.kt | 5 +- .../nonLocalReturnFromInlineLambdaDeep.kt | 5 +- .../codegen/box/coroutines/returnByLabel.kt | 5 +- .../testData/codegen/box/coroutines/simple.kt | 5 +- .../codegen/box/coroutines/simpleException.kt | 5 +- .../box/coroutines/simpleWithHandleResult.kt | 5 +- .../coroutines/stackUnwinding/exception.kt | 1 + .../stackUnwinding/inlineSuspendFunction.kt | 1 + .../box/coroutines/stackUnwinding/simple.kt | 1 + .../stackUnwinding/suspendInCycle.kt | 5 +- .../coroutines/statementLikeLastExpression.kt | 5 +- .../box/coroutines/suspendDelegation.kt | 5 +- .../box/coroutines/suspendFromInlineLambda.kt | 5 +- .../suspendFunctionTypeCall/manyParameters.kt | 5 +- .../suspendFunctionTypeCall/simple.kt | 5 +- .../codegen/box/coroutines/suspendInCycle.kt | 9 ++-- .../suspendInTheMiddleOfObjectConstruction.kt | 13 ++--- .../tryCatchFinallyWithHandleResult.kt | 9 ++-- .../coroutines/tryCatchWithHandleResult.kt | 9 ++-- .../tryFinallyInsideInlineLambda.kt | 5 +- .../coroutines/tryFinallyWithHandleResult.kt | 9 ++-- .../unitTypeReturn/coroutineNonLocalReturn.kt | 5 +- .../unitTypeReturn/coroutineReturn.kt | 5 +- .../unitTypeReturn/suspendNonLocalReturn.kt | 5 +- .../unitTypeReturn/suspendReturn.kt | 5 +- .../coroutines/varValueConflictsWithTable.kt | 5 +- .../varValueConflictsWithTableSameSort.kt | 5 +- .../bytecodeListing/coroutineFields.kt | 3 +- .../codegen/bytecodeText/constCoroutine.kt | 4 +- .../intLikeVarSpilling/complicatedMerge.kt | 5 +- .../intLikeVarSpilling/i2bResult.kt | 5 +- .../loadFromBooleanArray.kt | 5 +- .../intLikeVarSpilling/loadFromByteArray.kt | 5 +- .../intLikeVarSpilling/noVariableInTable.kt | 5 +- .../intLikeVarSpilling/sameIconst1ManyVars.kt | 5 +- .../intLikeVarSpilling/usedInArrayStore.kt | 5 +- .../intLikeVarSpilling/usedInMethodCall.kt | 5 +- .../intLikeVarSpilling/usedInPutfield.kt | 5 +- .../intLikeVarSpilling/usedInVarStore.kt | 5 +- .../coroutines/varValueConflictsWithTable.kt | 3 +- .../varValueConflictsWithTableSameSort.kt | 3 +- compiler/testData/codegen/java8/box/async.kt | 5 +- .../codegen/java8/box/asyncException.kt | 5 +- .../coroutinesBinary.kt | 5 +- .../coroutines/suspendCoroutineOrReturn.kt | 9 ++-- .../tests/coroutines/tailCalls/forbidden.kt | 7 +-- .../tailCalls/nothingTypedSuspendFunction.kt | 5 +- .../tests/coroutines/tailCalls/tryCatch.kt | 7 +-- .../tests/coroutines/tailCalls/valid.kt | 7 +-- .../src/kotlin/coroutines/Coroutines.kt | 37 --------------- .../coroutines/intrinsics/Intrinsics.kt | 47 +++++++++++++++++++ .../kotlin/builtins/KotlinBuiltIns.java | 13 +++-- .../src/kotlin/jvm/internal/CoroutineImpl.kt | 5 +- .../inlineFunCallSite/coroutine/usage.kt | 3 +- js/js.libraries/src/core/coroutines.kt | 15 +++--- .../callTranslator/CallTranslator.kt | 15 +----- .../expression/LiteralFunctionTranslator.kt | 10 ++-- .../kotlin/coroutines/CoroutinesLibrary.kt | 16 +++---- .../reference-public-api/kotlin-runtime.txt | 15 ++---- 119 files changed, 446 insertions(+), 348 deletions(-) create mode 100644 core/builtins/src/kotlin/coroutines/intrinsics/Intrinsics.kt diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/commonCoroutineCodegenUtil.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/commonCoroutineCodegenUtil.kt index 6b1b77fd1af..36a8f788d27 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/commonCoroutineCodegenUtil.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/commonCoroutineCodegenUtil.kt @@ -19,12 +19,24 @@ package org.jetbrains.kotlin.backend.common import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -val SUSPEND_WITH_CURRENT_CONTINUATION_NAME = Name.identifier("suspendWithCurrentContinuation") +val SUSPEND_COROUTINE_OR_RETURN_NAME = Name.identifier("suspendCoroutineOrReturn") val CONTINUATION_RESUME_METHOD_NAME = Name.identifier("resume") +val SUSPENDED_MARKER_NAME = Name.identifier("SUSPENDED_MARKER") -fun FunctionDescriptor.getBuiltInSuspendWithCurrentContinuation() = - builtIns.builtInsCoroutinePackageFragment.getMemberScope() - .getContributedFunctions(SUSPEND_WITH_CURRENT_CONTINUATION_NAME, NoLookupLocation.FROM_BACKEND) +fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturn(): Boolean { + if (name != SUSPEND_COROUTINE_OR_RETURN_NAME) return false + + val originalDeclaration = getBuiltInSuspendCoroutineOrReturn() ?: return false + + return DescriptorEquivalenceForOverrides.areEquivalent( + originalDeclaration, this + ) +} + +fun FunctionDescriptor.getBuiltInSuspendCoroutineOrReturn() = + builtIns.builtInsCoroutineIntrinsicsPackageFragment.getMemberScope() + .getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND) .singleOrNull() diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt index 00659a97145..50d59c83146 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutineCodegenUtil.kt @@ -17,22 +17,20 @@ package org.jetbrains.kotlin.codegen.coroutines import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.backend.common.SUSPEND_WITH_CURRENT_CONTINUATION_NAME -import org.jetbrains.kotlin.backend.common.getBuiltInSuspendWithCurrentContinuation +import org.jetbrains.kotlin.backend.common.SUSPENDED_MARKER_NAME +import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineOrReturn import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType import org.jetbrains.kotlin.codegen.binding.CodegenBinding import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl -import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingTraceContext import org.jetbrains.kotlin.resolve.DelegatingBindingTrace -import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides import org.jetbrains.kotlin.resolve.calls.model.* import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy @@ -175,22 +173,15 @@ private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction() = arguments = listOf(returnType!!.asTypeProjection()) ) -fun FunctionDescriptor.isBuiltInSuspendWithCurrentContinuation(): Boolean { - if (name != SUSPEND_WITH_CURRENT_CONTINUATION_NAME) return false +fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm() = + getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineOrReturn() == true - val originalDeclaration = getBuiltInSuspendWithCurrentContinuation() ?: return false - - return DescriptorEquivalenceForOverrides.areEquivalent( - originalDeclaration, this.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) - ) -} - -fun createMethodNodeForSuspendWithCurrentContinuation( +fun createMethodNodeForSuspendCoroutineOrReturn( functionDescriptor: FunctionDescriptor, typeMapper: KotlinTypeMapper ): MethodNode { - assert(functionDescriptor.isBuiltInSuspendWithCurrentContinuation()) { - "functionDescriptor must be kotlin.coroutines.suspendWithCurrentContinuation" + assert(functionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm()) { + "functionDescriptor must be kotlin.coroutines.intrinsics.suspendOrReturn" } val node = @@ -220,12 +211,9 @@ fun CallableDescriptor?.unwrapInitialDescriptorForSuspendFunction() = (this as? SimpleFunctionDescriptor)?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) ?: this fun InstructionAdapter.loadSuspendMarker() { - getstatic( - AsmTypes.COROUTINES_INTRINSICS.internalName, JvmAbi.INSTANCE_FIELD, AsmTypes.COROUTINES_INTRINSICS.descriptor - ) - invokevirtual( - AsmTypes.COROUTINES_INTRINSICS.internalName, - "getSUSPENDED", + invokestatic( + AsmTypes.COROUTINES_INTRINSICS_FILE_FACADE.internalName, + "get$SUSPENDED_MARKER_NAME", Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE), false ) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java index 7cb83614905..0c8614cd321 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java @@ -248,9 +248,9 @@ public class InlineCodegen extends CallGenerator { ); return new SMAPAndMethodNode(node, SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1)); } - else if (CoroutineCodegenUtilKt.isBuiltInSuspendWithCurrentContinuation(functionDescriptor)) { + else if (CoroutineCodegenUtilKt.isBuiltInSuspendCoroutineOrReturnInJvm(functionDescriptor)) { return new SMAPAndMethodNode( - CoroutineCodegenUtilKt.createMethodNodeForSuspendWithCurrentContinuation( + CoroutineCodegenUtilKt.createMethodNodeForSuspendCoroutineOrReturn( functionDescriptor, codegen.getState().getTypeMapper() ), SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java index a2f26045ce7..2058ff2fdb4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java @@ -42,7 +42,7 @@ public class AsmTypes { public static final Type MUTABLE_PROPERTY_REFERENCE2 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference2"); public static final Type COROUTINE_IMPL = Type.getObjectType("kotlin/jvm/internal/CoroutineImpl"); public static final Type RESTRICTED_COROUTINE_IMPL = Type.getObjectType("kotlin/jvm/internal/RestrictedCoroutineImpl"); - public static final Type COROUTINES_INTRINSICS = Type.getObjectType("kotlin/coroutines/CoroutineIntrinsics"); + public static final Type COROUTINES_INTRINSICS_FILE_FACADE = Type.getObjectType("kotlin/coroutines/intrinsics/IntrinsicsKt"); public static final Type CONTINUATION = Type.getObjectType("kotlin/coroutines/Continuation"); diff --git a/compiler/testData/builtin-classes/default/kotlin-coroutines.txt b/compiler/testData/builtin-classes/default/kotlin-coroutines.txt index 2a68d04fe2f..89fd3e87806 100644 --- a/compiler/testData/builtin-classes/default/kotlin-coroutines.txt +++ b/compiler/testData/builtin-classes/default/kotlin-coroutines.txt @@ -1,7 +1,5 @@ package-fragment kotlin.coroutines -@kotlin.PublishedApi internal inline suspend fun suspendWithCurrentContinuation(/*0*/ body: (kotlin.coroutines.Continuation) -> kotlin.Any?): T - @kotlin.SinceKotlin(version = "1.1") public interface Continuation { public abstract fun resume(/*0*/ value: T): kotlin.Unit public abstract fun resumeWithException(/*0*/ exception: kotlin.Throwable): kotlin.Unit @@ -12,13 +10,6 @@ package-fragment kotlin.coroutines public open fun dispatchResumeWithException(/*0*/ exception: kotlin.Throwable, /*1*/ continuation: kotlin.coroutines.Continuation<*>): kotlin.Boolean } -@kotlin.SinceKotlin(version = "1.1") public object CoroutineIntrinsics { - /*primary*/ private constructor CoroutineIntrinsics() - @kotlin.SinceKotlin(version = "1.1") public final val SUSPENDED: kotlin.Any - public final fun (): kotlin.Any - public final inline suspend fun suspendCoroutineOrReturn(/*0*/ block: (kotlin.coroutines.Continuation) -> kotlin.Any?): T -} - @kotlin.SinceKotlin(version = "1.1") @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class RestrictsSuspension : kotlin.Annotation { /*primary*/ public constructor RestrictsSuspension() } diff --git a/compiler/testData/codegen/box/coroutines/asyncIterator.kt b/compiler/testData/codegen/box/coroutines/asyncIterator.kt index 027eeb08845..e2612049622 100644 --- a/compiler/testData/codegen/box/coroutines/asyncIterator.kt +++ b/compiler/testData/codegen/box/coroutines/asyncIterator.kt @@ -1,6 +1,7 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* interface AsyncGenerator { suspend fun yield(value: T) @@ -33,18 +34,18 @@ class AsyncGeneratorIterator: AsyncIterator, AsyncGenerator, Continuati var computesNext = false var computeContinuation: Continuation<*>? = null - suspend fun computeHasNext(): Boolean = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun computeHasNext(): Boolean = suspendCoroutineOrReturn { c -> computesNext = false computeContinuation = c nextStep!!.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun computeNext(): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun computeNext(): T = suspendCoroutineOrReturn { c -> computesNext = true computeContinuation = c nextStep!!.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } @Suppress("UNCHECKED_CAST") @@ -90,12 +91,12 @@ class AsyncGeneratorIterator: AsyncIterator, AsyncGenerator, Continuati } // Generator implementation - override suspend fun yield(value: T): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + override suspend fun yield(value: T): Unit = suspendCoroutineOrReturn { c -> computedNext = true nextValue = value nextStep = c resumeIterator(null) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/await.kt b/compiler/testData/codegen/box/coroutines/await.kt index 093436eb720..78f9d099dd0 100644 --- a/compiler/testData/codegen/box/coroutines/await.kt +++ b/compiler/testData/codegen/box/coroutines/await.kt @@ -2,6 +2,7 @@ // WITH_COROUTINES // FILE: promise.kt import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Promise(private val executor: ((T) -> Unit) -> Unit) { private var value: Any? = null @@ -49,6 +50,7 @@ fun processQueue() { // FILE: await.kt import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* private var log = "" @@ -65,7 +67,6 @@ suspend fun await(value: Promise): S = suspendCoroutine { continuation -> } } inAwait = false - CoroutineIntrinsics.SUSPENDED } suspend fun awaitAndLog(value: Promise): S { @@ -95,6 +96,7 @@ fun getLog() = log // FILE: main.kt import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* private fun test() = async { val o = await(asyncOperation { "O" }) diff --git a/compiler/testData/codegen/box/coroutines/beginWithException.kt b/compiler/testData/codegen/box/coroutines/beginWithException.kt index bcc6ec8b478..dceb1f97dce 100644 --- a/compiler/testData/codegen/box/coroutines/beginWithException.kt +++ b/compiler/testData/codegen/box/coroutines/beginWithException.kt @@ -1,8 +1,9 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): Any = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> } +suspend fun suspendHere(): Any = suspendCoroutineOrReturn { x -> } fun builder(c: suspend () -> Unit) { var exception: Throwable? = null diff --git a/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt b/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt index fc1142ec9a5..6948a917de6 100644 --- a/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt +++ b/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt @@ -1,7 +1,8 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* -suspend fun suspendHere(): Any = CoroutineIntrinsics.suspendCoroutineOrReturn { x ->} +import kotlin.coroutines.intrinsics.* +suspend fun suspendHere(): Any = suspendCoroutineOrReturn { x ->} fun builder(c: suspend () -> Unit) { try { diff --git a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt index ac01525766c..fd32cf70a8f 100644 --- a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt +++ b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun await(t: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> +suspend fun await(t: T): T = suspendCoroutineOrReturn { c -> c.resume(t) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit): String { diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt index d49e8c0179c..c1e5b5ef513 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt index 8aff6f5a2ff..2afb66fed33 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt index 932fc621dd7..ffb6aac5099 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt b/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt index e1ff99af922..a68269835d4 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt index 5de02f0b5f4..1aa4b2bdcca 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt index e7816fb694f..dad5ab4a7d4 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt index e02800269b8..523e9ef3db2 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendAndLog(value: T): T = suspendCoroutineOrReturn { c -> result += "suspend($value);" c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt b/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt index cf386e60c97..d6bceae838f 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt @@ -1,15 +1,16 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> result += "[" c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt index ce70aa13d49..a3b1c63b951 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt @@ -1,22 +1,23 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendAndLog(value: T): T = suspendCoroutineOrReturn { c -> result += "suspend($value);" c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } // Tail calls are not allowed to be Nothing typed. See KT-15051 - suspend fun suspendLogAndThrow(exception: Throwable): Any? = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendLogAndThrow(exception: Throwable): Any? = suspendCoroutineOrReturn { c -> result += "throw(${exception.message});" c.resumeWithException(exception) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt index 6fd8bd06afd..f65566187ef 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt @@ -1,15 +1,16 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendAndLog(value: T): T = suspendCoroutineOrReturn { c -> result += "suspend($value);" c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt index bfd9670c2c8..8090e40d633 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" - suspend fun suspendWithResult(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend fun suspendWithResult(value: T): T = suspendCoroutineOrReturn { c -> c.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt index d2ce1e4b381..a22cd7526f6 100644 --- a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt +++ b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt @@ -1,12 +1,13 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = false - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun foo() { diff --git a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt index c6feea4f052..b9d0226e122 100644 --- a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt +++ b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(a: String = "abc", i: Int = 2): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(a: String = "abc", i: Int = 2): String = suspendCoroutineOrReturn { x -> x.resume(a + "#" + (i + 1)) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/dispatchResume.kt b/compiler/testData/codegen/box/coroutines/dispatchResume.kt index c09f21dec45..455ab3bee0f 100644 --- a/compiler/testData/codegen/box/coroutines/dispatchResume.kt +++ b/compiler/testData/codegen/box/coroutines/dispatchResume.kt @@ -1,21 +1,22 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var log = "" var resumeIndex = 0 - suspend fun suspendWithValue(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { continuation -> + suspend fun suspendWithValue(value: T): T = suspendCoroutineOrReturn { continuation -> log += "suspend($value);" continuation.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithException(value: String): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { continuation -> + suspend fun suspendWithException(value: String): Unit = suspendCoroutineOrReturn { continuation -> log += "error($value);" continuation.resumeWithException(RuntimeException(value)) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/emptyClosure.kt b/compiler/testData/codegen/box/coroutines/emptyClosure.kt index 9a648c512c0..8094bf4ea4d 100644 --- a/compiler/testData/codegen/box/coroutines/emptyClosure.kt +++ b/compiler/testData/codegen/box/coroutines/emptyClosure.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var result = 0 class Controller { - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> result++ x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt index a2a1d712017..8d5f2ad9de6 100644 --- a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt +++ b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(v: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(v: T): T = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/generate.kt b/compiler/testData/codegen/box/coroutines/generate.kt index 47c94806875..f78fc9e0c62 100644 --- a/compiler/testData/codegen/box/coroutines/generate.kt +++ b/compiler/testData/codegen/box/coroutines/generate.kt @@ -2,6 +2,7 @@ // WITH_COROUTINES // FULL_JDK import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun box(): String { val x = gen().joinToString() @@ -50,10 +51,10 @@ class GeneratedIterator(block: suspend Generator.() -> Unit) : AbstractIte override fun computeNext() { nextStep.resume(Unit) } - suspend override fun yield(value: T) = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> + suspend override fun yield(value: T) = suspendCoroutineOrReturn { c -> setNext(value) nextStep = c - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/handleException.kt b/compiler/testData/codegen/box/coroutines/handleException.kt index 56935d5bbeb..be4eb86bf9d 100644 --- a/compiler/testData/codegen/box/coroutines/handleException.kt +++ b/compiler/testData/codegen/box/coroutines/handleException.kt @@ -1,25 +1,26 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var exception: Throwable? = null val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithException(e: Exception): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun run(c: suspend Controller.() -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt b/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt index 2efaebac409..b9eb3a6bc1c 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt @@ -1,6 +1,7 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun builder(c: suspend () -> Unit): String { diff --git a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt index 0943e13080a..841363b99be 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt index c97385948e3..7b7859cccad 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var log = "" - suspend fun suspendAndLog(value: T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendAndLog(value: T): T = suspendCoroutineOrReturn { x -> log += "suspend($value);" x.resume(value) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/illegalState.kt b/compiler/testData/codegen/box/coroutines/illegalState.kt index 88cb58acb02..6cefd4a0e2f 100644 --- a/compiler/testData/codegen/box/coroutines/illegalState.kt +++ b/compiler/testData/codegen/box/coroutines/illegalState.kt @@ -2,10 +2,11 @@ // WITH_COROUTINES // TARGET_BACKEND: JVM import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder1(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt index ec2de0105a3..c31fe6d2cc7 100644 --- a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt +++ b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt @@ -5,15 +5,16 @@ // CHECK_NOT_CALLED: suspendInline_6r51u9$ // CHECK_NOT_CALLED: suspendInline import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { fun withValue(v: String, x: Continuation) { x.resume(v) } - suspend inline fun suspendInline(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend inline fun suspendInline(v: String): String = suspendCoroutineOrReturn { x -> withValue(v, x) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } suspend inline fun suspendInline(crossinline b: () -> String): String = suspendInline(b()) diff --git a/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt b/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt index 43029d735ec..dd803039834 100644 --- a/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt +++ b/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt @@ -1,26 +1,27 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var globalResult = "" var wasCalled = false class Controller { val postponedActions = mutableListOf<() -> Unit>() - suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithException(e: Exception): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt index 19de56f9200..3a17dd7dd84 100644 --- a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt +++ b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt @@ -1,12 +1,13 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var i = 0 - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume((i++).toString()) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt index dab09664ad8..bb2d0f32248 100644 --- a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt +++ b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt @@ -2,18 +2,19 @@ // WITH_COROUTINES // WITH_REFLECT import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun runInstanceOf(): Boolean = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun runInstanceOf(): Boolean = suspendCoroutineOrReturn { x -> val y: Any = x x.resume(x is Continuation<*>) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun runCast(): Boolean = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun runCast(): Boolean = suspendCoroutineOrReturn { x -> val y: Any = x x.resume(Continuation::class.isInstance(y as Continuation<*>)) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt index 86a5c981bac..42d7cac2929 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt index 32eaf28ec3f..2b2d665be72 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt index 48bc273b3ea..2409129a56a 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt index d9e615db484..b80ae0714b7 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt index 5ba69a2ee1c..df7af8d271c 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt index 87a8b21cbf7..372e237f685 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt index 96eda9cfad5..6b091928145 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TARGET_BACKEND: JVM import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt index 2de332b53a2..e23cf66b5ef 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt index 47aeadcf71d..ecf3605cfcf 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TARGET_BACKEND: JVM import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt index 4568620869f..1343bbeaaa5 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt index a9bb1b5c742..39aad3dd897 100644 --- a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt +++ b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/kt12958.kt b/compiler/testData/codegen/box/coroutines/kt12958.kt index 0ec9c8f8330..1ac633f9ba8 100644 --- a/compiler/testData/codegen/box/coroutines/kt12958.kt +++ b/compiler/testData/codegen/box/coroutines/kt12958.kt @@ -2,10 +2,11 @@ // WITH_COROUTINES // WITH_CONTINUATION import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(v: V): V = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(v: V): V = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> String): String { diff --git a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt index 965ec182d8a..9cb8ba844a6 100644 --- a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt +++ b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var result = "" var ok = false - suspend fun suspendHere(v: String): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(v: String): Unit = suspendCoroutineOrReturn { x -> result += v x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt index b24c04d1cb3..fb75e1ef35e 100644 --- a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt +++ b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt index f04c11cede8..97ce5df1edb 100644 --- a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt +++ b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt index 79e7352fe06..9ff80f2a9f5 100644 --- a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt @@ -1,14 +1,15 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var ok = false var v = "fail" - suspend fun suspendHere(v: String): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(v: String): Unit = suspendCoroutineOrReturn { x -> this.v = v x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt index fe81fa42641..91e8b51b9ae 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt @@ -9,6 +9,7 @@ inline fun foo(x: String = "OK"): String { // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var result = "" diff --git a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt index 3f7c8a605bc..135bce26064 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt @@ -5,11 +5,12 @@ package lib import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } @@ -17,6 +18,7 @@ class Controller { // FILE: main.kt import lib.* import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun builder(c: suspend Controller.() -> Unit) { c.startCoroutine(Controller(), EmptyContinuation) diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt index 892ea72c0bd..e0c45449385 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt @@ -1,13 +1,14 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> lastSuspension = x - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt index 3926e11eb52..02878b2e11b 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt @@ -1,13 +1,14 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> lastSuspension = x - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt index fdf83f31294..7a8201139b7 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt @@ -1,13 +1,14 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> lastSuspension = x - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt index 5dac65520ee..8d8453da3b0 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt @@ -1,13 +1,14 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var lastSuspension: Continuation? = null var result = "fail" - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> lastSuspension = x - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun hasNext() = lastSuspension != null diff --git a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt index 2e7b27f929e..d146063ef13 100644 --- a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt +++ b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt @@ -1,26 +1,27 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var globalResult = "" var wasCalled = false class Controller { val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithException(e: Exception): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt b/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt index 5a8a13d4fe6..fbc3b18aa54 100644 --- a/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt +++ b/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt @@ -1,6 +1,7 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun builder(c: suspend () -> Int): Int { diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt index ac8d1592ed7..4f45ffb4e28 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt @@ -1,12 +1,13 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var cResult = 0 - suspend fun suspendHere(v: Int): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(v: Int): Int = suspendCoroutineOrReturn { x -> x.resume(v * 2) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt index 9c0de6fadad..68f996aac48 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt @@ -1,13 +1,14 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var cResult = 0 - suspend fun suspendHere(v: Int): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(v: Int): Int = suspendCoroutineOrReturn { x -> x.resume(v * 2) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/returnByLabel.kt b/compiler/testData/codegen/box/coroutines/returnByLabel.kt index 583aa33bbc8..0b7d4b20948 100644 --- a/compiler/testData/codegen/box/coroutines/returnByLabel.kt +++ b/compiler/testData/codegen/box/coroutines/returnByLabel.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Int): Int { diff --git a/compiler/testData/codegen/box/coroutines/simple.kt b/compiler/testData/codegen/box/coroutines/simple.kt index d640d67f0ba..bbdeff17c8c 100644 --- a/compiler/testData/codegen/box/coroutines/simple.kt +++ b/compiler/testData/codegen/box/coroutines/simple.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/simpleException.kt b/compiler/testData/codegen/box/coroutines/simpleException.kt index 06999f19879..313d9c898c0 100644 --- a/compiler/testData/codegen/box/coroutines/simpleException.kt +++ b/compiler/testData/codegen/box/coroutines/simpleException.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resumeWithException(RuntimeException("OK")) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt index d6f61c1fee3..4d6c632299e 100644 --- a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Int): Int { diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt index 04294aa9e4b..5b0c2b4f3d6 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/exception.kt @@ -1,6 +1,7 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { suspend fun suspendHere(): String = throw RuntimeException("OK") diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt index 6708e8a2714..ec5310fcecc 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/inlineSuspendFunction.kt @@ -5,6 +5,7 @@ // CHECK_NOT_CALLED: suspendInline_6r51u9$ // CHECK_NOT_CALLED: suspendInline import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { suspend inline fun suspendInline(v: String): String = v diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt index 31e1bc7f640..04b178eda69 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt @@ -1,6 +1,7 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { suspend fun suspendHere() = "OK" diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt index 7810fea43ec..04d0308065b 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt @@ -1,12 +1,13 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Int = suspendCoroutineOrReturn { x -> 1 } - suspend fun suspendThere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendThere(): String = suspendCoroutineOrReturn { x -> "?" } } diff --git a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt index 197969c80f2..9ecc7e75d69 100644 --- a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt +++ b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var globalResult = "" -suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> String) { diff --git a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt index 7e0b04a51fc..3c41abd2ee6 100644 --- a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt +++ b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt @@ -1,13 +1,14 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { suspend fun suspendHere(): String = suspendThere() - suspend fun suspendThere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendThere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt index f77e3ac11b4..6da0daeb684 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(v: Int): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(v: Int): Int = suspendCoroutineOrReturn { x -> x.resume(v * 2) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt index de436c53998..dd9fd88a0d0 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(v: String): String = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt index 10c2b655e73..76aaca07936 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(v: String): String = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt index d59e9c44fcf..5b64735a3fa 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt @@ -1,16 +1,17 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { var i = 0 - suspend fun suspendHere(): Int = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Int = suspendCoroutineOrReturn { x -> x.resume(i++) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendThere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendThere(): String = suspendCoroutineOrReturn { x -> x.resume("?") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt index 95114878c23..752143b4cd6 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt @@ -1,21 +1,22 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("K") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithArgument(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithArgument(v: String): String = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithDouble(v: Double): Double = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithDouble(v: Double): Double = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt index c94ec80e3ba..b80883195c8 100644 --- a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt @@ -1,26 +1,27 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var globalResult = "" var wasCalled = false class Controller { val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithException(e: Exception): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt index 8be35219df5..53333e11da3 100644 --- a/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt @@ -1,26 +1,27 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var globalResult = "" var wasCalled = false class Controller { val postponedActions = ArrayList<() -> Unit>() - suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithException(e: Exception): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt index 202481ee123..0cf0e6c861d 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt @@ -1,12 +1,13 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(v: String): String = suspendCoroutineOrReturn { x -> x.resume(v) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt index c539516da92..d2e10fcafa1 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt @@ -1,26 +1,27 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var globalResult = "" var wasCalled = false class Controller { val postponedActions = mutableListOf<() -> Unit>() - suspend fun suspendWithValue(v: String): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resume(v) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } - suspend fun suspendWithException(e: Exception): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendWithException(e: Exception): String = suspendCoroutineOrReturn { x -> postponedActions.add { x.resumeWithException(e) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun run(c: suspend Controller.() -> String) { diff --git a/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineNonLocalReturn.kt b/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineNonLocalReturn.kt index 0f462b8a2fe..62a6d70037a 100644 --- a/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineNonLocalReturn.kt +++ b/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineNonLocalReturn.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineReturn.kt b/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineReturn.kt index b237e7cf158..be09587accd 100644 --- a/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineReturn.kt +++ b/compiler/testData/codegen/box/coroutines/unitTypeReturn/coroutineReturn.kt @@ -1,10 +1,11 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } fun builder(c: suspend () -> Unit) { diff --git a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt index f0d6919046e..7bb61e3f2fa 100644 --- a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt +++ b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt @@ -2,6 +2,7 @@ // WITH_COROUTINES // IGNORE_BACKEND: JS import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var result = "0" @@ -13,9 +14,9 @@ suspend fun suspendHere(x: Int): Unit { } result = "OK" - return CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + return suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt index 589be86c2eb..d04878faa34 100644 --- a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt +++ b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt @@ -1,15 +1,16 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* var result = "0" suspend fun suspendHere(x: Int): Unit { if (x == 0) return result = "OK" - return CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + return suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt index a0c7415d6aa..9d597a81f1f 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt index d0eb7032a76..d5ca545e3a4 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt @@ -1,11 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeListing/coroutineFields.kt b/compiler/testData/codegen/bytecodeListing/coroutineFields.kt index 9d0880ec8a0..ae3eba16d9d 100644 --- a/compiler/testData/codegen/bytecodeListing/coroutineFields.kt +++ b/compiler/testData/codegen/bytecodeListing/coroutineFields.kt @@ -1,7 +1,8 @@ // WITH_RUNTIME import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere() = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere() = suspendCoroutineOrReturn { x -> x.resume("OK") } } diff --git a/compiler/testData/codegen/bytecodeText/constCoroutine.kt b/compiler/testData/codegen/bytecodeText/constCoroutine.kt index 0564cfa7240..66142e25e27 100644 --- a/compiler/testData/codegen/bytecodeText/constCoroutine.kt +++ b/compiler/testData/codegen/bytecodeText/constCoroutine.kt @@ -2,6 +2,7 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* suspend fun suspendHere() = "" fun builder(c: suspend () -> Unit) { @@ -21,5 +22,4 @@ fun box(): String { // 2 GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit; // 1 GETSTATIC EmptyContinuation.INSTANCE -// 2 GETSTATIC kotlin/coroutines/CoroutineIntrinsics.INSTANCE -// 5 GETSTATIC +// 3 GETSTATIC diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt index bdad437a9bf..4ecedd2e78d 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/complicatedMerge.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt index 20efdec2df0..aea850b6961 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/i2bResult.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt index 70824cfeaae..7e8f8698ee6 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt index 3a98f01d6ac..d5022da5169 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/loadFromByteArray.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt index 32705aba0b5..9ec7398904f 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/noVariableInTable.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt index 2980becbe55..7156ef7052a 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt index 8b9f38b9416..c4d4a55bcd7 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInArrayStore.kt @@ -3,11 +3,12 @@ // TREAT_AS_ONE_FILE // TARGET_BACKEND: JVM import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt index c4259f71a2f..f442e152685 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInMethodCall.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt index d15591bf98a..457b0f73bc7 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInPutfield.kt @@ -3,11 +3,12 @@ // TREAT_AS_ONE_FILE // TARGET_BACKEND: JVM import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt index 2f69ad8849a..da71ccb3571 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling/usedInVarStore.kt @@ -2,11 +2,12 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere(): Unit = suspendCoroutineOrReturn { x -> x.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt index e1ac21d080b..de8bb1390f8 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt @@ -2,7 +2,8 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +import kotlin.coroutines.intrinsics.* +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt index f7a36a4790b..ee3018c1cc0 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTableSameSort.kt @@ -2,7 +2,8 @@ // WITH_COROUTINES // TREAT_AS_ONE_FILE import kotlin.coroutines.* -suspend fun suspendHere(): String = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> +import kotlin.coroutines.intrinsics.* +suspend fun suspendHere(): String = suspendCoroutineOrReturn { x -> x.resume("OK") } diff --git a/compiler/testData/codegen/java8/box/async.kt b/compiler/testData/codegen/java8/box/async.kt index ffcb44f9bec..ca8e7b30792 100644 --- a/compiler/testData/codegen/java8/box/async.kt +++ b/compiler/testData/codegen/java8/box/async.kt @@ -3,6 +3,7 @@ import java.util.concurrent.CompletableFuture import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun foo(): CompletableFuture = CompletableFuture.supplyAsync { "foo" } fun bar(v: String): CompletableFuture = CompletableFuture.supplyAsync { "bar with $v" } @@ -58,12 +59,12 @@ fun async(c: suspend () -> T): CompletableFuture { return future } -suspend fun await(f: CompletableFuture) = CoroutineIntrinsics.suspendCoroutineOrReturn { machine -> +suspend fun await(f: CompletableFuture) = suspendCoroutineOrReturn { machine -> f.whenComplete { value, throwable -> if (throwable == null) machine.resume(value) else machine.resumeWithException(throwable) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } diff --git a/compiler/testData/codegen/java8/box/asyncException.kt b/compiler/testData/codegen/java8/box/asyncException.kt index b83991c6495..e9cb842c9fa 100644 --- a/compiler/testData/codegen/java8/box/asyncException.kt +++ b/compiler/testData/codegen/java8/box/asyncException.kt @@ -3,6 +3,7 @@ import java.util.concurrent.CompletableFuture import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun exception(v: String): CompletableFuture = CompletableFuture.supplyAsync { throw RuntimeException(v) } @@ -55,12 +56,12 @@ fun async(c: suspend () -> T): CompletableFuture { return future } -suspend fun await(f: CompletableFuture) = CoroutineIntrinsics.suspendCoroutineOrReturn { machine -> +suspend fun await(f: CompletableFuture) = suspendCoroutineOrReturn { machine -> f.whenComplete { value, throwable -> if (throwable == null) machine.resume(value) else machine.resumeWithException(throwable) } - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } diff --git a/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt b/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt index 78300a2f8b3..a0a177b3e23 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt @@ -2,11 +2,12 @@ package a import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun suspendHere() = CoroutineIntrinsics.suspendCoroutineOrReturn { x -> + suspend fun suspendHere() = suspendCoroutineOrReturn { x -> x.resume("OK") - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } } diff --git a/compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.kt b/compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.kt index 674e6aa8260..1b1edcacd1b 100644 --- a/compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.kt +++ b/compiler/testData/diagnostics/tests/coroutines/suspendCoroutineOrReturn.kt @@ -1,23 +1,24 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* class Controller { - suspend fun noParams(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn { + suspend fun noParams(): Unit = suspendCoroutineOrReturn { if (hashCode() % 2 == 0) { it.resume(Unit) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } else { Unit } } - suspend fun yieldString(value: String) = CoroutineIntrinsics.suspendCoroutineOrReturn { + suspend fun yieldString(value: String) = suspendCoroutineOrReturn { it.resume(1) it checkType { _>() } it.resume("") - // We can return anything here, 'CoroutineIntrinsics.suspendCoroutineOrReturn' is not very type-safe + // We can return anything here, 'suspendCoroutineOrReturn' is not very type-safe // Also we can call resume and then return the value too, but it's still just our problem "Not-int" } diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt index cb04b04e2d9..c454baf2b25 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/forbidden.kt @@ -1,18 +1,19 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun nonSuspend() {} suspend fun foo() { - CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + suspendCoroutineOrReturn { x: Continuation -> } nonSuspend() } suspend fun unitSuspend() { - CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + suspendCoroutineOrReturn { x: Continuation -> } } suspend fun baz(): Int = run { - CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + suspendCoroutineOrReturn { x: Continuation -> } } diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt index 30320a67f0e..b4f784f23b9 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/nothingTypedSuspendFunction.kt @@ -1,7 +1,8 @@ // Tail calls are not allowed to be Nothing typed. See KT-15051 import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* -suspend fun suspendLogAndThrow(exception: Throwable): Nothing = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> +suspend fun suspendLogAndThrow(exception: Throwable): Nothing = suspendCoroutineOrReturn { c -> c.resumeWithException(exception) - CoroutineIntrinsics.SUSPENDED + SUSPENDED_MARKER } diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt index 8833b925b7b..ab487edc8f1 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/tryCatch.kt @@ -1,5 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun nonSuspend() {} @@ -7,7 +8,7 @@ suspend fun baz(): Int = 1 suspend fun tryCatch(): Int { return try { - CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + suspendCoroutineOrReturn { x: Continuation -> } } catch (e: Exception) { baz() // another suspend function } @@ -15,7 +16,7 @@ suspend fun tryCatch(): Int { suspend fun tryFinally(): Int { return try { - CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + suspendCoroutineOrReturn { x: Continuation -> } } finally { nonSuspend() } @@ -31,7 +32,7 @@ suspend fun returnInFinally(): Int { suspend fun tryCatchFinally(): Int { return try { - CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + suspendCoroutineOrReturn { x: Continuation -> } } catch (e: Exception) { baz() // another suspend function } finally { diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt index eaf1cec49f6..35905ed83b5 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/valid.kt @@ -1,5 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* suspend fun baz() = 1 @@ -14,17 +15,17 @@ suspend fun bar1() { return if (1.hashCode() > 0) { foo() } - else CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + else suspendCoroutineOrReturn { x: Continuation -> } } suspend fun bar2() = if (1.hashCode() > 0) { foo() } - else CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + else suspendCoroutineOrReturn { x: Continuation -> } suspend fun bar3() = when { true -> { foo() } - else -> CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation -> } + else -> suspendCoroutineOrReturn { x: Continuation -> } } diff --git a/core/builtins/src/kotlin/coroutines/Coroutines.kt b/core/builtins/src/kotlin/coroutines/Coroutines.kt index 941b81090af..945e4a028bb 100644 --- a/core/builtins/src/kotlin/coroutines/Coroutines.kt +++ b/core/builtins/src/kotlin/coroutines/Coroutines.kt @@ -60,40 +60,3 @@ public interface ContinuationDispatcher { @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) public annotation class RestrictsSuspension - -/** - * Contains intrinsic functions for coroutines. - */ -@SinceKotlin("1.1") -public object CoroutineIntrinsics { - /** - * Obtains the current continuation instance inside suspend functions and either suspend - * currently running coroutine or return result immediately without suspension. - * - * If the [block] returns the special [SUSPENDED] value, it means that suspend function did suspend the execution and will - * not return any result immediately. In this case, the [Continuation] provided to the [block] shall be invoked at some moment in the - * future when the result becomes available to resume the computation. - * - * Otherwise, the return value of the [block] must have a type assignable to [T] and represents the result of this suspend function. - * It means that the execution was not suspended and the [Continuation] provided to the [block] shall not be invoked. - * As the result type of the [block] is declared as `Any?` and cannot be correctly type-checked, - * its proper return type remains on the conscience of the suspend function's author. - * - * Note that it is not recommended to call either [Continuation.resume] nor [Continuation.resumeWithException] functions synchronously - * in the same stackframe where suspension function is run. Use [suspendCoroutine] as a safer way to obtain current - * continuation instance. - */ - public inline suspend fun suspendCoroutineOrReturn( - block: (Continuation) -> Any? - ): T = suspendWithCurrentContinuation(block) - - /** - * 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. - */ - @SinceKotlin("1.1") - public val SUSPENDED: Any = Any() -} - -@PublishedApi -internal inline suspend fun suspendWithCurrentContinuation(body: (Continuation) -> Any?): T = null!! diff --git a/core/builtins/src/kotlin/coroutines/intrinsics/Intrinsics.kt b/core/builtins/src/kotlin/coroutines/intrinsics/Intrinsics.kt new file mode 100644 index 00000000000..79253399eaf --- /dev/null +++ b/core/builtins/src/kotlin/coroutines/intrinsics/Intrinsics.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.coroutines.intrinsics + +import kotlin.coroutines.Continuation + +/** + * Obtains the current continuation instance inside suspend functions and either suspend + * currently running coroutine or return result immediately without suspension. + * + * If the [block] returns the special [SUSPENDED_MARKER] value, it means that suspend function did suspend the execution and will + * not return any result immediately. In this case, the [Continuation] provided to the [block] shall be invoked at some moment in the + * future when the result becomes available to resume the computation. + * + * Otherwise, the return value of the [block] must have a type assignable to [T] and represents the result of this suspend function. + * It means that the execution was not suspended and the [Continuation] provided to the [block] shall not be invoked. + * As the result type of the [block] is declared as `Any?` and cannot be correctly type-checked, + * its proper return type remains on the conscience of the suspend function's author. + * + * Note that it is not recommended to call either [Continuation.resume] nor [Continuation.resumeWithException] functions synchronously + * in the same stackframe where suspension function is run. Use [suspendCoroutine] as a safer way to obtain current + * continuation instance. + */ +@SinceKotlin("1.1") +public inline suspend fun suspendCoroutineOrReturn(block: (Continuation) -> Any?): T = null!! + +/** + * 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. + */ +@SinceKotlin("1.1") +public val SUSPENDED_MARKER: Any = Any() + diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 1d05d73265e..1ea49c2d670 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -58,6 +58,7 @@ public abstract class KotlinBuiltIns { private static final FqName ANNOTATION_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("annotation")); public static final FqName COLLECTIONS_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("collections")); public static final FqName COROUTINES_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("coroutines")); + private static final FqName COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics")); public static final FqName RANGES_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("ranges")); public static final FqName TEXT_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("text")); @@ -68,6 +69,7 @@ public abstract class KotlinBuiltIns { ANNOTATION_PACKAGE_FQ_NAME, ReflectionTypesKt.getKOTLIN_REFLECT_FQ_NAME(), COROUTINES_PACKAGE_FQ_NAME, + COROUTINES_INTRINSICS_PACKAGE_FQ_NAME, BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("internal")) ); @@ -97,10 +99,12 @@ public abstract class KotlinBuiltIns { createPackage(provider, nameToFragment, RANGES_PACKAGE_FQ_NAME); PackageFragmentDescriptor kotlinAnnotation = createPackage(provider, nameToFragment, ANNOTATION_PACKAGE_FQ_NAME); PackageFragmentDescriptor coroutinePackage = createPackage(provider, null, COROUTINES_PACKAGE_FQ_NAME); + PackageFragmentDescriptor coroutineIntrinsicsPackage = + createPackage(provider, null, COROUTINES_INTRINSICS_PACKAGE_FQ_NAME); Set allImportedByDefault = new LinkedHashSet(nameToFragment.values()); - return new PackageFragments(kotlin, kotlinCollections, kotlinAnnotation, coroutinePackage, allImportedByDefault); + return new PackageFragments(kotlin, kotlinCollections, kotlinAnnotation, coroutinePackage, coroutineIntrinsicsPackage, allImportedByDefault); } }); @@ -249,6 +253,7 @@ public abstract class KotlinBuiltIns { public final PackageFragmentDescriptor collectionsPackageFragment; public final PackageFragmentDescriptor annotationPackageFragment; public final PackageFragmentDescriptor coroutinePackageFragment; + public final PackageFragmentDescriptor coroutineIntrinsicsPackage; public final Set allImportedByDefaultBuiltInsPackageFragments; private PackageFragments( @@ -256,12 +261,14 @@ public abstract class KotlinBuiltIns { @NotNull PackageFragmentDescriptor collectionsPackageFragment, @NotNull PackageFragmentDescriptor annotationPackageFragment, @NotNull PackageFragmentDescriptor coroutinePackageFragment, + @NotNull PackageFragmentDescriptor coroutineIntrinsicsPackage, @NotNull Set allImportedByDefaultBuiltInsPackageFragments ) { this.builtInsPackageFragment = builtInsPackageFragment; this.collectionsPackageFragment = collectionsPackageFragment; this.annotationPackageFragment = annotationPackageFragment; this.coroutinePackageFragment = coroutinePackageFragment; + this.coroutineIntrinsicsPackage = coroutineIntrinsicsPackage; this.allImportedByDefaultBuiltInsPackageFragments = allImportedByDefaultBuiltInsPackageFragments; } } @@ -392,8 +399,8 @@ public abstract class KotlinBuiltIns { } @NotNull - public PackageFragmentDescriptor getBuiltInsCoroutinePackageFragment() { - return packageFragments.invoke().coroutinePackageFragment; + public PackageFragmentDescriptor getBuiltInsCoroutineIntrinsicsPackageFragment() { + return packageFragments.invoke().coroutineIntrinsicsPackage; } @NotNull diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/CoroutineImpl.kt b/core/runtime.jvm/src/kotlin/jvm/internal/CoroutineImpl.kt index 8837bee0f18..93c31127234 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/CoroutineImpl.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/CoroutineImpl.kt @@ -17,6 +17,7 @@ package kotlin.jvm.internal import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.SUSPENDED_MARKER private const val INTERCEPT_BIT_SET = 1 shl 31 private const val INTERCEPT_BIT_CLEAR = INTERCEPT_BIT_SET.inv() @@ -73,7 +74,7 @@ abstract class RestrictedCoroutineImpl : Lambda, Continuation { override fun resume(value: Any?) { try { val result = doResume(value, null) - if (result != CoroutineIntrinsics.SUSPENDED) + if (result != SUSPENDED_MARKER) completion!!.resume(result) } catch (e: Throwable) { completion!!.resumeWithException(e) @@ -83,7 +84,7 @@ abstract class RestrictedCoroutineImpl : Lambda, Continuation { override fun resumeWithException(exception: Throwable) { try { val result = doResume(null, exception) - if (result != CoroutineIntrinsics.SUSPENDED) + if (result != SUSPENDED_MARKER) completion!!.resume(result) } catch (e: Throwable) { completion!!.resumeWithException(e) diff --git a/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt b/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt index d2c7c5c40a7..e2f22122e52 100644 --- a/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt +++ b/jps-plugin/testData/incremental/inlineFunCallSite/coroutine/usage.kt @@ -1,5 +1,6 @@ package usage import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* fun async(x: suspend Controller.() -> Unit) { x.startCoroutine(Controller(), object : Continuation { @@ -10,7 +11,7 @@ fun async(x: suspend Controller.() -> Unit) { } class Controller { - suspend fun step(param: Int) = CoroutineIntrinsics.suspendCoroutineOrReturn { next -> + suspend fun step(param: Int) = suspendCoroutineOrReturn { next -> next.resume(param + 1) } } diff --git a/js/js.libraries/src/core/coroutines.kt b/js/js.libraries/src/core/coroutines.kt index b723267dc23..f84da4bf5d4 100644 --- a/js/js.libraries/src/core/coroutines.kt +++ b/js/js.libraries/src/core/coroutines.kt @@ -16,6 +16,7 @@ package kotlin.coroutines +import kotlin.coroutines.intrinsics.* /** * Creates coroutine with receiver type [R] and result type [T]. @@ -82,7 +83,7 @@ public fun (suspend () -> T).startCoroutine( * from a different thread of execution. Repeated invocation of any resume function produces [IllegalStateException]. */ @SinceKotlin("1.1") -public suspend fun suspendCoroutine(block: (Continuation) -> Unit): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c -> +public suspend fun suspendCoroutine(block: (Continuation) -> Unit): T = suspendCoroutineOrReturn { c -> val safe = SafeContinuation(c) block(safe) safe.getResult() @@ -128,7 +129,7 @@ internal abstract class CoroutineImpl(private val resultContinuation: Continuati this.result = data try { val result = doResume() - if (result != CoroutineIntrinsics.SUSPENDED) { + if (result != SUSPENDED_MARKER) { resultContinuation.resume(result) } } @@ -142,7 +143,7 @@ internal abstract class CoroutineImpl(private val resultContinuation: Continuati this.exception = exception try { val result = doResume() - if (result != CoroutineIntrinsics.SUSPENDED) { + if (result != SUSPENDED_MARKER) { resultContinuation.resume(result) } } @@ -180,7 +181,7 @@ internal class SafeContinuation internal constructor(private val delegate: UNDECIDED -> { result = value } - CoroutineIntrinsics.SUSPENDED -> { + SUSPENDED_MARKER -> { result = RESUMED delegate.resume(value) } @@ -195,7 +196,7 @@ internal class SafeContinuation internal constructor(private val delegate: UNDECIDED -> { result = Fail(exception) } - CoroutineIntrinsics.SUSPENDED -> { + SUSPENDED_MARKER -> { result = RESUMED delegate.resumeWithException(exception) } @@ -207,12 +208,12 @@ internal class SafeContinuation internal constructor(private val delegate: internal fun getResult(): Any? { if (result == UNDECIDED) { - result = CoroutineIntrinsics.SUSPENDED + result = SUSPENDED_MARKER } val result = this.result return when (result) { RESUMED -> { - CoroutineIntrinsics.SUSPENDED // already called continuation, indicate SUSPENDED upstream + SUSPENDED_MARKER // already called continuation, indicate SUSPENDED upstream } is Fail -> { throw result.exception diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt index 16b5638938d..494e22b35a2 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt @@ -16,10 +16,9 @@ package org.jetbrains.kotlin.js.translate.callTranslator -import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineOrReturn import org.jetbrains.kotlin.builtins.isFunctionTypeOrSubtype import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.js.backend.ast.* @@ -33,14 +32,12 @@ import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils import org.jetbrains.kotlin.js.translate.utils.JsAstUtils import org.jetbrains.kotlin.js.translate.utils.TranslationUtils import org.jetbrains.kotlin.js.translate.utils.setInlineCallMetadata -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.Call.CallType import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInvokeCallOnVariable import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.* -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.inline.InlineStrategy import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue @@ -135,7 +132,7 @@ private fun translateFunctionCall( explicitReceivers: ExplicitReceivers ): JsExpression { val descriptorToCall = resolvedCall.resultingDescriptor - if (descriptorToCall is FunctionDescriptor && descriptorToCall.isSuspendCoroutineOrReturn()) { + if (descriptorToCall is FunctionDescriptor && descriptorToCall.original.isBuiltInSuspendCoroutineOrReturn()) { return translateCallWithContinuation(context, resolvedCall) } @@ -160,14 +157,6 @@ private fun translateFunctionCall( return callExpression } -private val SUSPEND_COROUTINE_OR_RETURN = Name.identifier("suspendCoroutineOrReturn") -private val COROUTINE_INTRINSICS = KotlinBuiltIns.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")) - -private fun FunctionDescriptor.isSuspendCoroutineOrReturn(): Boolean { - val containingClass = containingDeclaration as? ClassDescriptor ?: return false - return containingClass.fqNameSafe == COROUTINE_INTRINSICS && name == SUSPEND_COROUTINE_OR_RETURN -} - private fun translateCallWithContinuation(context: TranslationContext, resolvedCall: ResolvedCall): JsExpression { val arguments = CallArgumentTranslator.translate(resolvedCall, null, context) val coroutineArgument = TranslationUtils.getEnclosingContinuationParameter(context) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LiteralFunctionTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LiteralFunctionTranslator.kt index b31d6b1b1d1..3fd5c8e58e6 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LiteralFunctionTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LiteralFunctionTranslator.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.js.translate.expression +import org.jetbrains.kotlin.backend.common.SUSPENDED_MARKER_NAME import org.jetbrains.kotlin.builtins.isBuiltinExtensionFunctionalType import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl @@ -46,8 +47,7 @@ import org.jetbrains.kotlin.types.KotlinType class LiteralFunctionTranslator(context: TranslationContext) : AbstractTranslator(context) { companion object { - private val SUSPEND_NAME = Name.identifier("SUSPENDED") - private val COROUTINE_INTRINSICS_FQ_NAME = FqName("kotlin.coroutines.CoroutineIntrinsics") + private val COROUTINE_INTRINSICS_PACKAGE_FQ_NAME = FqName("kotlin.coroutines.intrinsics") } fun translate( @@ -114,10 +114,8 @@ class LiteralFunctionTranslator(context: TranslationContext) : AbstractTranslato fun JsFunction.fillCoroutineMetadata(context: TranslationContext, continuationType: KotlinType?) { if (continuationType == null) return - val suspendPropertyDescriptor = context().currentModule.getPackage(COROUTINE_INTRINSICS_FQ_NAME.parent()) - .memberScope.getContributedClassifier(COROUTINE_INTRINSICS_FQ_NAME.shortName(), NoLookupLocation.FROM_BACKEND) - .let { (it as ClassDescriptor) }.unsubstitutedMemberScope - .getContributedVariables(SUSPEND_NAME, NoLookupLocation.FROM_BACKEND).first() + val suspendPropertyDescriptor = context().currentModule.getPackage(COROUTINE_INTRINSICS_PACKAGE_FQ_NAME) + .memberScope.getContributedVariables(SUSPENDED_MARKER_NAME, NoLookupLocation.FROM_BACKEND).first() val coroutineBaseClassRef = ReferenceTranslator.translateAsTypeReference(TranslationUtils.getCoroutineBaseClass(context), context) diff --git a/libraries/stdlib/src/kotlin/coroutines/CoroutinesLibrary.kt b/libraries/stdlib/src/kotlin/coroutines/CoroutinesLibrary.kt index 741ee7559a7..66a37355b70 100644 --- a/libraries/stdlib/src/kotlin/coroutines/CoroutinesLibrary.kt +++ b/libraries/stdlib/src/kotlin/coroutines/CoroutinesLibrary.kt @@ -2,9 +2,9 @@ @file:kotlin.jvm.JvmVersion package kotlin.coroutines -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater import java.lang.IllegalStateException -import kotlin.coroutines.CoroutineIntrinsics.SUSPENDED +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater +import kotlin.coroutines.intrinsics.* /** * Creates coroutine with receiver type [R] and result type [T]. @@ -76,7 +76,7 @@ public fun (suspend () -> T).startCoroutine( */ @SinceKotlin("1.1") public inline suspend fun suspendCoroutine(crossinline block: (Continuation) -> Unit): T = - CoroutineIntrinsics.suspendCoroutineOrReturn { c: Continuation -> + suspendCoroutineOrReturn { c: Continuation -> val safe = SafeContinuation(c) block(safe) safe.getResult() @@ -116,7 +116,7 @@ internal class SafeContinuation @PublishedApi internal constructor(private val result = this.result // atomic read when (result) { UNDECIDED -> if (cas(UNDECIDED, value)) return - SUSPENDED -> if (cas(SUSPENDED, RESUMED)) { + SUSPENDED_MARKER -> if (cas(SUSPENDED_MARKER, RESUMED)) { delegate.resume(value) return } @@ -130,7 +130,7 @@ internal class SafeContinuation @PublishedApi internal constructor(private val result = this.result // atomic read when (result) { UNDECIDED -> if (cas(UNDECIDED, Fail(exception))) return - SUSPENDED -> if (cas(SUSPENDED, RESUMED)) { + SUSPENDED_MARKER -> if (cas(SUSPENDED_MARKER, RESUMED)) { delegate.resumeWithException(exception) return } @@ -143,13 +143,13 @@ internal class SafeContinuation @PublishedApi internal constructor(private internal fun getResult(): Any? { var result = this.result // atomic read if (result == UNDECIDED) { - if (cas(UNDECIDED, SUSPENDED)) return SUSPENDED + if (cas(UNDECIDED, SUSPENDED_MARKER)) return SUSPENDED_MARKER result = this.result // reread volatile var } when (result) { - RESUMED -> return SUSPENDED // already called continuation, indicate SUSPENDED upstream + RESUMED -> return SUSPENDED_MARKER // already called continuation, indicate SUSPENDED_MARKER upstream is Fail -> throw result.exception - else -> return result // either SUSPENDED or data + else -> return result // either SUSPENDED_MARKER or data } } } diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt index a7f3d717d3a..b4ef83525cd 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt @@ -194,19 +194,14 @@ public final class kotlin/coroutines/ContinuationDispatcher$DefaultImpls { public static fun dispatchResumeWithException (Lkotlin/coroutines/ContinuationDispatcher;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Z } -public final class kotlin/coroutines/CoroutineIntrinsics { - public static final field INSTANCE Lkotlin/coroutines/CoroutineIntrinsics; - public final fun getSUSPENDED ()Ljava/lang/Object; - public final fun suspendCoroutineOrReturn (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class kotlin/coroutines/CoroutinesKt { - public static final fun suspendWithCurrentContinuation (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - public abstract interface annotation class kotlin/coroutines/RestrictsSuspension : java/lang/annotation/Annotation { } +public final class kotlin/coroutines/intrinsics/IntrinsicsKt { + public static final fun getSUSPENDED_MARKER ()Ljava/lang/Object; + public static final fun suspendCoroutineOrReturn (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public final class kotlin/jvm/JvmClassMappingKt { public static final fun getAnnotationClass (Ljava/lang/annotation/Annotation;)Lkotlin/reflect/KClass; public static final fun getJavaClass (Ljava/lang/Object;)Ljava/lang/Class;