JVM_IR: Copy suspend lambda's attributes

This commit is contained in:
Ilmir Usmanov
2019-08-01 22:14:58 +03:00
parent 88e5d2bc70
commit d9caeca249
3 changed files with 8 additions and 3 deletions
@@ -108,6 +108,7 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
private fun generateContinuationClassForLambda(info: SuspendLambdaInfo) {
val suspendLambda = suspendLambda.owner
suspendLambda.createContinuationClassFor(info.function).apply {
copyAttributes(info.reference)
val functionNClass = context.ir.symbols.getJvmFunctionClass(info.arity + 1)
superTypes.add(
IrSimpleTypeImpl(
@@ -443,7 +444,11 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
expression.acceptChildrenVoid(this)
if (expression.isSuspend) {
suspendLambdas += SuspendLambdaInfo(expression.symbol.owner, (expression.type as IrSimpleType).arguments.size - 1)
suspendLambdas += SuspendLambdaInfo(
expression.symbol.owner,
(expression.type as IrSimpleType).arguments.size - 1,
expression
)
}
}
})
@@ -552,7 +557,7 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
}
}
private class SuspendLambdaInfo(val function: IrFunction, val arity: Int) {
private class SuspendLambdaInfo(val function: IrFunction, val arity: Int, val reference: IrFunctionReference) {
lateinit var constructor: IrConstructor
}
}
@@ -1,4 +1,5 @@
// KJS_WITH_FULL_RUNTIME
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// WITH_COROUTINES
import helpers.*