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:
+6
@@ -16226,6 +16226,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
+10
-1
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_FULL_RUNTIME
|
||||
|
||||
fun <T : Result<*>> isSuccess(a: A<T>): String =
|
||||
a.go {
|
||||
it.isSuccess
|
||||
}
|
||||
|
||||
class A<T> {
|
||||
fun go(f: (T) -> Boolean): String =
|
||||
if (f(Result.success(1) as T)) "OK" else "Fail"
|
||||
}
|
||||
|
||||
fun box(): String = isSuccess(A<Result<Int>>())
|
||||
+6
@@ -16226,6 +16226,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
+6
@@ -16226,6 +16226,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
|
||||
+5
@@ -14222,6 +14222,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -12177,6 +12177,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
|
||||
|
||||
Generated
+5
@@ -12177,6 +12177,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
|
||||
|
||||
Generated
+5
@@ -12242,6 +12242,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -6648,6 +6648,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44141.kt")
|
||||
public void testKt44141() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
|
||||
|
||||
Reference in New Issue
Block a user