JVM_IR: Do not unbox Result parameter in invoke if there is a bridge

since the bridge unboxes it.

 #KT-44141 Fixed
This commit is contained in:
Ilmir Usmanov
2021-01-20 09:09:42 +01:00
parent 0ddb603eaa
commit d48f92775b
10 changed files with 67 additions and 1 deletions
@@ -629,6 +629,8 @@ class ExpressionCodegen(
if (irFunction !is IrSimpleFunction) return
// Skip Result's methods
if (irFunction.parentAsClass.fqNameWhenAvailable == StandardNames.RESULT_FQ_NAME) return
// Do not unbox, if there is a bridge, which unboxes for us
if (hasBridge()) return
val index = (arg.symbol as? IrValueParameterSymbol)?.owner?.index ?: return
val genericOrAnyOverride = irFunction.overriddenSymbols.any {
@@ -637,7 +639,14 @@ class ExpressionCodegen(
} || irFunction.parentAsClass.origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL
if (!genericOrAnyOverride) return
StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.toIrBasedKotlinType(), mv)
StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.erasedUpperBound.defaultType.toIrBasedKotlinType(), mv)
}
private fun hasBridge(): Boolean = irFunction.parentAsClass.declarations.any { function ->
function is IrFunction && function != irFunction &&
context.methodSignatureMapper.mapSignatureSkipGeneric(function).let {
it.asmMethod.name == signature.asmMethod.name && it.valueParameters == signature.valueParameters
}
}
override fun visitFieldAccess(expression: IrFieldAccessExpression, data: BlockInfo): PromisedValue {