Skip to content

Commit 85c5a8e

Browse files
JSMonkSpace Team
authored andcommitted
[K/JS] Fix simple suspend functions compilation using ES2015 generators
^KT-79359 Fixed
1 parent 36db4d7 commit 85c5a8e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/JsSuspendFunctionWithGeneratorsLowering.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class JsSuspendFunctionWithGeneratorsLowering(private val context: JsIrBackendCo
4747
}
4848

4949
private fun transformSuspendFunction(function: IrSimpleFunction): List<IrFunction>? {
50-
val originalReturnType = function.returnType.also { function.returnType = context.irBuiltIns.anyNType }
5150
val body = function.body ?: return null
5251
return when (val functionKind = getSuspendFunctionKind(context, function, body, includeSuspendLambda = false)) {
5352
is SuspendFunctionKind.NO_SUSPEND_CALLS -> null
@@ -56,6 +55,8 @@ class JsSuspendFunctionWithGeneratorsLowering(private val context: JsIrBackendCo
5655
null
5756
}
5857
is SuspendFunctionKind.NEEDS_STATE_MACHINE -> {
58+
val originalReturnType = function.returnType
59+
function.returnType = context.irBuiltIns.anyNType
5960
generateGeneratorAndItsWrapper(function, body, originalReturnType)
6061
}
6162
}

compiler/testData/codegen/box/coroutines/implicitUnitReturn.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// KT-79359
22
// TARGET_BACKEND: JS_IR
33
// TARGET_BACKEND: JS_IR_ES6
4-
// IGNORE_BACKEND: JS_IR_ES6
54
// WITH_STDLIB
65
// WITH_COROUTINES
76

0 commit comments

Comments
 (0)