JVM IR: Fix mangling for suspend functions with inline class params (KT-41374)

This commit is contained in:
Steven Schäfer
2020-08-31 14:59:44 +02:00
committed by Alexander Udalov
parent 48a3d4b8e0
commit 78ab957bfe
4 changed files with 40 additions and 2 deletions
@@ -100,8 +100,17 @@ object InlineClassAbi {
fun returnHashSuffix(irFunction: IrFunction) =
md5base64(":${irFunction.returnType.eraseToString()}")
private fun hashSuffix(irFunction: IrFunction) =
md5base64(irFunction.fullValueParameterList.joinToString { it.type.eraseToString() })
private fun hashSuffix(irFunction: IrFunction): String {
val signatureElementsForMangling =
irFunction.fullValueParameterList.mapTo(mutableListOf()) { it.type.eraseToString() }
if (irFunction.isSuspend) {
// The JVM backend computes mangled names after creating suspend function views, but before default argument
// stub insertion. It would be nice if this part of the continuation lowering happened earlier in the pipeline.
// TODO: Move suspend function view creation before JvmInlineClassLowering.
signatureElementsForMangling += "Lkotlin.coroutines.Continuation;"
}
return md5base64(signatureElementsForMangling.joinToString())
}
private fun IrType.eraseToString() = buildString {
append('L')