JVM IR: Avoid double mangling of function reference invoke methods

This commit is contained in:
Steven Schäfer
2021-04-27 15:33:39 +02:00
committed by Alexander Udalov
parent 276ffd5a4b
commit 84d78035e4
16 changed files with 210 additions and 9 deletions
@@ -574,15 +574,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
private fun createInvokeMethod(receiverVar: IrValueDeclaration?): IrSimpleFunction =
functionReferenceClass.addFunction {
setSourceRange(if (isLambda) callee else irFunctionReference)
name =
if (samSuperType == null && callee.returnType.isInlineClassType() &&
context.state.functionsWithInlineClassReturnTypesMangled
) {
// For functions with inline class return type we need to mangle the invoke method.
// Otherwise, bridge lowering may fail to generate bridges for inline class types erasing to Any.
val suffix = InlineClassAbi.hashReturnSuffix(callee)
Name.identifier("${superMethod.name.asString()}-${suffix}")
} else superMethod.name
name = superMethod.name
returnType = callee.returnType
isSuspend = callee.isSuspend
}.apply {