Restore order of lowerings

This commit is contained in:
Ilmir Usmanov
2019-06-06 16:06:57 +03:00
parent 60cbf0696d
commit 95a65ba94d
2 changed files with 4 additions and 2 deletions
@@ -115,10 +115,10 @@ val jvmPhases = namedIrFilePhase<JvmBackendContext>(
makePatchParentsPhase(1) then
enumWhenPhase then
singletonReferencesPhase then
localDeclarationsPhase then
singleAbstractMethodPhase then
addContinuationPhase then
singletonReferencesPhase then
callableReferencePhase then
functionNVarargInvokePhase then
@@ -169,6 +169,8 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
invokeSuspend: IrFunction,
invokeToOverride: IrSimpleFunctionSymbol
) {
val unitClass = context.irBuiltIns.unitClass
val unitField = context.declarationFactory.getFieldForObjectInstance(unitClass.owner)
addFunctionOverride(invokeToOverride.owner).also { function ->
function.body = context.createIrBuilder(function.symbol).irBlockBody {
+irReturn(irCall(invokeSuspend).also { invokeSuspendCall ->
@@ -178,7 +180,7 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
it.putValueArgument(index, irGet(param))
}
}
invokeSuspendCall.putValueArgument(0, irUnit())
invokeSuspendCall.putValueArgument(0, irGetField(null, unitField))
})
}
}