Generate $this$<label> as receiver name instead of $receiver

This commit is contained in:
Ilmir Usmanov
2019-03-28 21:23:37 +03:00
parent 6f14dcfacb
commit ea1e72e7b4
2 changed files with 9 additions and 7 deletions
@@ -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)
}
@@ -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