Do not use typeMapper to count number of coroutine parameters in MethodInliner

This commit is contained in:
Alexander Udalov
2019-08-30 14:14:08 +02:00
parent 2648fb2ddd
commit eb5e91d6bb
@@ -52,7 +52,6 @@ class MethodInliner(
private val inlineOnlySmapSkipper: InlineOnlySmapSkipper?, //non null only for root private val inlineOnlySmapSkipper: InlineOnlySmapSkipper?, //non null only for root
private val shouldPreprocessApiVersionCalls: Boolean = false private val shouldPreprocessApiVersionCalls: Boolean = false
) { ) {
private val typeMapper = inliningContext.state.typeMapper
private val languageVersionSettings = inliningContext.state.languageVersionSettings private val languageVersionSettings = inliningContext.state.languageVersionSettings
private val invokeCalls = ArrayList<InvokeCall>() private val invokeCalls = ArrayList<InvokeCall>()
//keeps order //keeps order
@@ -237,16 +236,13 @@ class MethodInliner(
var coroutineDesc = desc var coroutineDesc = desc
val actualInvokeDescriptor: FunctionDescriptor val actualInvokeDescriptor: FunctionDescriptor
if (info.invokeMethodDescriptor.isSuspend) { if (info.invokeMethodDescriptor.isSuspend) {
val coroutineInvokeMethodDescriptor = getOrCreateJvmSuspendFunctionView( actualInvokeDescriptor = getOrCreateJvmSuspendFunctionView(info.invokeMethodDescriptor, inliningContext.state)
info.invokeMethodDescriptor, val parametersSize = actualInvokeDescriptor.valueParameters.size +
inliningContext.state (if (actualInvokeDescriptor.extensionReceiverParameter != null) 1 else 0)
)
actualInvokeDescriptor = coroutineInvokeMethodDescriptor
val coroutineInvokeDesc = typeMapper.mapAsmMethod(coroutineInvokeMethodDescriptor).descriptor
// And here we expect invoke(...Ljava/lang/Object;) be replaced with invoke(...Lkotlin/coroutines/Continuation;) // And here we expect invoke(...Ljava/lang/Object;) be replaced with invoke(...Lkotlin/coroutines/Continuation;)
// if this does not happen, insert fake continuation, since we could not have one yet. // if this does not happen, insert fake continuation, since we could not have one yet.
val argumentTypes = Type.getArgumentTypes(desc) val argumentTypes = Type.getArgumentTypes(desc)
if (Type.getArgumentTypes(coroutineInvokeDesc).size != argumentTypes.size) { if (argumentTypes.size != parametersSize) {
addFakeContinuationMarker(this) addFakeContinuationMarker(this)
coroutineDesc = Type.getMethodDescriptor(Type.getReturnType(desc), *argumentTypes, AsmTypes.OBJECT_TYPE) coroutineDesc = Type.getMethodDescriptor(Type.getReturnType(desc), *argumentTypes, AsmTypes.OBJECT_TYPE)
} }