natario1
12/28/2022, 8:16 PMCompilation failed: Expected ‘BaseContinuationImpl.invokeSuspend’ but was ‘org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@7521bfb7’The compiler throws this error here if it helps.
natario1
12/28/2022, 8:17 PMfun irLambda(
context: IrGeneratorContext,
parent: IrDeclarationParent,
valueParameters: List<IrType>,
returnType: IrType,
suspend: Boolean = false,
content: IrBlockBodyBuilder.(IrSimpleFunction) -> Unit
): IrFunctionExpression {
val lambda = context.irFactory.buildFun {
startOffset = SYNTHETIC_OFFSET
endOffset = SYNTHETIC_OFFSET
origin = IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
name = Name.special("<anonymous>")
visibility = DescriptorVisibilities.LOCAL
isSuspend = suspend
this.returnType = returnType
}.apply {
this.parent = parent
valueParameters.forEachIndexed { index, type ->
addValueParameter("arg$index", type)
}
body = DeclarationIrBuilder(context, this.symbol, SYNTHETIC_OFFSET, SYNTHETIC_OFFSET).irBlockBody {
content(this@apply)
}
}
return IrFunctionExpressionImpl(
startOffset = SYNTHETIC_OFFSET,
endOffset = SYNTHETIC_OFFSET,
type = run {
when (suspend) {
true -> context.irBuiltIns.functionN(valueParameters.size)
else -> context.irBuiltIns.suspendFunctionN(valueParameters.size)
}.typeWith(*valueParameters.toTypedArray(), returnType)
},
origin = IrStatementOrigin.LAMBDA,
function = lambda
)
}
shikasd
12/29/2022, 8:35 AMIrStatementOrigin
or something like this
I suggest writing the desired code in Kotlin and then dumping IR, and then comparing with the dump of your custom lambdanatario1
12/29/2022, 12:03 PMtrue
instead of false
. Thanks for your help Andrei 🙏