JVM_IR: Support inner objects with multiple suspend functions

Do not clean `functionsToAdd`
This commit is contained in:
Ilmir Usmanov
2019-12-09 18:51:57 +03:00
parent a1448ebb37
commit daa76cbf1e
3 changed files with 6 additions and 6 deletions
@@ -560,13 +560,13 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
copyBodyFrom(function) copyBodyFrom(function)
copyAttributes(function) copyAttributes(function)
} }
functionsToAdd[function.parentAsClass] = mutableSetOf(newFunction) registerNewFunction(function.parentAsClass, newFunction)
} }
val newFunction = if (function.isOverridable) { val newFunction = if (function.isOverridable) {
// Create static method for the suspend state machine method so that reentering the method // Create static method for the suspend state machine method so that reentering the method
// does not lead to virtual dispatch to the wrong method. // does not lead to virtual dispatch to the wrong method.
functionsToAdd.getOrPut(function.parentAsClass) { mutableSetOf() }.add(function) registerNewFunction(function.parentAsClass, function)
createStaticSuspendImpl(function) createStaticSuspendImpl(function)
} else function } else function
@@ -602,6 +602,10 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
}) })
} }
private fun registerNewFunction(container: IrClass, function: IrFunction) {
functionsToAdd.getOrPut(container) { mutableSetOf() }.add(function)
}
private fun markSuspendLambdas(irElement: IrElement): Pair<List<SuspendLambdaInfo>, List<IrFunction>> { private fun markSuspendLambdas(irElement: IrElement): Pair<List<SuspendLambdaInfo>, List<IrFunction>> {
val suspendLambdas = arrayListOf<SuspendLambdaInfo>() val suspendLambdas = arrayListOf<SuspendLambdaInfo>()
val inlineLambdas = mutableSetOf<IrFunctionReference>() val inlineLambdas = mutableSetOf<IrFunctionReference>()
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
// FILE: inlined.kt // FILE: inlined.kt
// COMMON_COROUTINES_TEST // COMMON_COROUTINES_TEST
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
// COMMON_COROUTINES_TEST // COMMON_COROUTINES_TEST
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES