JVM IR: Mangle names of $$forInline functions

This commit is contained in:
Steven Schäfer
2021-01-07 16:17:48 +01:00
committed by Alexander Udalov
parent 7cc06489dd
commit dad10e94aa
6 changed files with 32 additions and 3 deletions
@@ -98,8 +98,10 @@ internal fun IrFunction.suspendForInlineToOriginal(): IrSimpleFunction? {
origin != JvmLoweredDeclarationOrigin.FOR_INLINE_STATE_MACHINE_TEMPLATE_CAPTURES_CROSSINLINE
) return null
return parentAsClass.declarations.find {
it is IrSimpleFunction && it.attributeOwnerId == (this as IrSimpleFunction).attributeOwnerId &&
it.name.asString() + FOR_INLINE_SUFFIX == name.asString()
// The function may not be named `it.name.asString() + FOR_INLINE_SUFFIX` due to name mangling,
// e.g., for internal declarations. We check for a function with the same `attributeOwnerId` instead.
// This is copied in `AddContinuationLowering`.
it is IrSimpleFunction && it.attributeOwnerId == (this as IrSimpleFunction).attributeOwnerId
} as IrSimpleFunction?
}
@@ -285,7 +285,7 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower
if (flag.capturesCrossinline || function.isInline) {
result += context.irFactory.buildFun {
containerSource = view.containerSource
name = Name.identifier(view.name.asString() + FOR_INLINE_SUFFIX)
name = Name.identifier(context.methodSignatureMapper.mapFunctionName(view) + FOR_INLINE_SUFFIX)
returnType = view.returnType
modality = view.modality
isSuspend = view.isSuspend