JVM IR: Fix receiver types in AddContinuationLowering
This commit is contained in:
committed by
Georgy Bronnikov
parent
a4414829bc
commit
0e243ca295
+15
-3
@@ -12,11 +12,11 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.IrInlineReferenceLocator
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.defaultValue
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInvokeSuspendForInlineOfLambda
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInvokeSuspendOfContinuation
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInvokeSuspendOfLambda
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.IrInlineReferenceLocator
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.defaultValue
|
||||
import org.jetbrains.kotlin.backend.jvm.localDeclarationsPhase
|
||||
import org.jetbrains.kotlin.codegen.coroutines.*
|
||||
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
|
||||
@@ -73,6 +73,18 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
|
||||
return super.visitFunction(declaration).also { functionStack.pop() }
|
||||
}
|
||||
|
||||
override fun visitMemberAccess(expression: IrMemberAccessExpression): IrExpression {
|
||||
val receiverType = expression.dispatchReceiver?.type
|
||||
val newExpression = super.visitMemberAccess(expression) as IrMemberAccessExpression
|
||||
if (receiverType != null && receiverType != newExpression.dispatchReceiver?.type) {
|
||||
newExpression.dispatchReceiver = IrTypeOperatorCallImpl(
|
||||
expression.startOffset, expression.endOffset, receiverType,
|
||||
IrTypeOperator.IMPLICIT_CAST, receiverType, newExpression.dispatchReceiver!!
|
||||
)
|
||||
}
|
||||
return newExpression
|
||||
}
|
||||
|
||||
override fun visitCall(expression: IrCall): IrExpression {
|
||||
// This is a property, no need to add continuation parameter, since this cannot be suspend call
|
||||
if (functionStack.isEmpty()) return super.visitCall(expression)
|
||||
@@ -825,4 +837,4 @@ private fun IrCall.createSuspendFunctionCallViewIfNeeded(context: JvmBackendCont
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user