diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 4d60198825c..78df49652d8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -595,8 +595,31 @@ public class FunctionCodegen { @NotNull KotlinTypeMapper typeMapper, int shiftForDestructuringVariables ) { - generateLocalVariablesForParameters(mv, jvmMethodSignature, thisType, methodBegin, methodEnd, - functionDescriptor.getValueParameters(), + if (functionDescriptor.isSuspend()) { + FunctionDescriptor unwrapped = CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction( + functionDescriptor + ); + + if (unwrapped != functionDescriptor) { + generateLocalVariableTable( + mv, + new JvmMethodSignature( + jvmMethodSignature.getAsmMethod(), + jvmMethodSignature.getValueParameters().subList( + 0, + jvmMethodSignature.getValueParameters().size() - 1 + ) + ), + unwrapped, + thisType, methodBegin, methodEnd, ownerKind, typeMapper, shiftForDestructuringVariables + ); + return; + } + } + + generateLocalVariablesForParameters(mv, + jvmMethodSignature, + thisType, methodBegin, methodEnd, functionDescriptor.getValueParameters(), AsmUtil.isStaticMethod(ownerKind, functionDescriptor), typeMapper, shiftForDestructuringVariables ); } diff --git a/compiler/testData/codegen/bytecodeText/coroutines/doNotReassignContinuation.kt b/compiler/testData/codegen/bytecodeText/coroutines/doNotReassignContinuation.kt index 6185ede2818..7fbb856a110 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/doNotReassignContinuation.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/doNotReassignContinuation.kt @@ -14,5 +14,4 @@ suspend fun suspendThere(param: Int, param2: String, param3: Long): String { return a + b } -/* 2 stores happen because the continuation parameter is visible in debug and should be spilled */ -// 2 ASTORE 4 +// 0 ASTORE 4