diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt index 0d18c1e2bea..6c72bc707f3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt @@ -22,10 +22,7 @@ import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.KtCallableReferenceExpression -import org.jetbrains.kotlin.psi.KtDeclarationWithBody -import org.jetbrains.kotlin.psi.KtElement -import org.jetbrains.kotlin.psi.KtFunction +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.descriptorUtil.module @@ -431,8 +428,10 @@ class CoroutineCodegenForLambda private constructor( v.store(newIndex, mappedType) val name = - if (parameter is ReceiverParameterDescriptor) AsmUtil.RECEIVER_PARAMETER_NAME - else (getNameForDestructuredParameterOrNull(parameter as ValueParameterDescriptor) ?: parameter.name.asString()) + if (parameter is ReceiverParameterDescriptor) + AsmUtil.getNameForReceiverParameter(originalSuspendFunctionDescriptor, bindingContext, languageVersionSettings) + else + (getNameForDestructuredParameterOrNull(parameter as ValueParameterDescriptor) ?: parameter.name.asString()) val label = Label() v.mark(label) v.visitLocalVariable(name, mappedType.descriptor, null, label, endLabel, newIndex) @@ -478,6 +477,9 @@ class CoroutineCodegenForLambda private constructor( } override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) { + if (element is KtFunctionLiteral) { + recordCallLabelForLambdaArgument(element, state.bindingTrace) + } codegen.initializeCoroutineParameters() super.doGenerateBody(codegen, signature) } diff --git a/compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/parameters.kt b/compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/parameters.kt index 9f32349ee98..8a53002ca19 100644 --- a/compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/parameters.kt +++ b/compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/parameters.kt @@ -13,7 +13,7 @@ suspend fun foo(data: Data, body: suspend Long.(String, Data, Int) -> Unit) { } // METHOD : ParametersKt$test$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object; -// VARIABLE : NAME=$receiver TYPE=J INDEX=2 +// VARIABLE : NAME=$this$foo TYPE=J INDEX=2 // VARIABLE : NAME=str TYPE=Ljava/lang/String; INDEX=4 // VARIABLE : NAME=$dstr$x$_u24__u24$z TYPE=LData; INDEX=5 // VARIABLE : NAME=i TYPE=I INDEX=6