IC Mangling: Do not mangle functions with inline classes from Java

in JVM_IR BE. Map types to boxed variants, when mapping signatures.
 #KT-26445
This commit is contained in:
Ilmir Usmanov
2020-12-10 13:00:59 +01:00
parent 0cab69a7a0
commit cbb8eb494a
2 changed files with 8 additions and 3 deletions
@@ -195,7 +195,8 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
// See also: KotlinTypeMapper.forceBoxedReturnType
private fun forceBoxedReturnType(function: IrFunction): Boolean =
isBoxMethodForInlineClass(function) || forceFoxedReturnTypeOnOverride(function) || forceBoxedReturnTypeOnDefaultImplFun(function)
isBoxMethodForInlineClass(function) || forceFoxedReturnTypeOnOverride(function) || forceBoxedReturnTypeOnDefaultImplFun(function) ||
function.isFromJava() && function.returnType.isInlined()
private fun forceFoxedReturnTypeOnOverride(function: IrFunction) =
function is IrSimpleFunction &&
@@ -320,7 +321,11 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
private fun writeParameterType(sw: JvmSignatureWriter, type: IrType, declaration: IrDeclaration) {
if (sw.skipGenericSignature()) {
typeMapper.mapType(type, TypeMappingMode.DEFAULT, sw)
if (type.isInlined() && declaration.isFromJava()) {
typeMapper.mapType(type, TypeMappingMode.GENERIC_ARGUMENT, sw)
} else {
typeMapper.mapType(type, TypeMappingMode.DEFAULT, sw)
}
return
}
@@ -81,7 +81,7 @@ class MemoizedInlineClassReplacements(
}
// Otherwise, mangle functions with mangled parameters, ignoring constructors
it is IrSimpleFunction && (it.hasMangledParameters || mangleReturnTypes && it.hasMangledReturnType) ->
it is IrSimpleFunction && !it.isFromJava() && (it.hasMangledParameters || mangleReturnTypes && it.hasMangledReturnType) ->
if (it.dispatchReceiverParameter != null)
createMethodReplacement(it)
else