From 953089a4b942fb03507e617edac3e0cc113850f8 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Fri, 12 Nov 2021 13:34:25 +0300 Subject: [PATCH] [JS IR] suport SuspendN.invoke functions --- .../coroutines/AddContinuationToFunctionCallsLowering.kt | 5 ++--- .../lower/coroutines/AddContinuationToFunctionsLowering.kt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionCallsLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionCallsLowering.kt index 2ccda86fca1..bf76f5e4eac 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionCallsLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionCallsLowering.kt @@ -62,9 +62,8 @@ class AddContinuationToFunctionCallsLowering(val context: JsCommonBackendContext } val oldFun = expression.symbol.owner - val newFun: IrSimpleFunction = - context.mapping.suspendFunctionsToFunctionWithContinuations[oldFun] - ?: error("No mapping for ${oldFun.fqNameWhenAvailable}") + // TODO: investigate why mapping might be unavailable for SuspendFunction4.invoke + val newFun: IrSimpleFunction = oldFun.getOrCreateFunctionWithContinuationStub(context) return irCall( expression, diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionsLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionsLowering.kt index 447977e2d96..063513334f7 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionsLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/AddContinuationToFunctionsLowering.kt @@ -85,7 +85,7 @@ private fun transformSuspendFunction(context: JsCommonBackendContext, function: } -private fun IrSimpleFunction.getOrCreateFunctionWithContinuationStub(context: JsCommonBackendContext): IrSimpleFunction { +fun IrSimpleFunction.getOrCreateFunctionWithContinuationStub(context: JsCommonBackendContext): IrSimpleFunction { return context.mapping.suspendFunctionsToFunctionWithContinuations.getOrPut(this) { createSuspendFunctionStub(context) }