From 95a65ba94d5b8a17b4265100867b986050f563a6 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Thu, 6 Jun 2019 16:06:57 +0300 Subject: [PATCH] Restore order of lowerings --- .../src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt | 2 +- .../kotlin/backend/jvm/lower/AddContinuationLowering.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt index eb8be531bb0..84975e1baaf 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt @@ -115,10 +115,10 @@ val jvmPhases = namedIrFilePhase( makePatchParentsPhase(1) then enumWhenPhase then + singletonReferencesPhase then localDeclarationsPhase then singleAbstractMethodPhase then addContinuationPhase then - singletonReferencesPhase then callableReferencePhase then functionNVarargInvokePhase then diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index c5dbc848a6a..d6361d1abb9 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -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)) }) } }