JVM_IR: Do not unbox Result parameter in Result methods

#KT-44140 Fixed
This commit is contained in:
Ilmir Usmanov
2021-01-19 12:28:02 +01:00
parent 10d9259df5
commit cce9469e6a
10 changed files with 58 additions and 0 deletions
@@ -16328,6 +16328,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt");
}
@Test
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@Test
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
@@ -637,6 +637,8 @@ class ExpressionCodegen(
private fun unboxResultIfNeeded(arg: IrGetValue) {
if (arg.type.erasedUpperBound.fqNameWhenAvailable != StandardNames.RESULT_FQ_NAME) return
if (irFunction !is IrSimpleFunction) return
// Skip Result's methods
if (irFunction.parentAsClass.fqNameWhenAvailable == StandardNames.RESULT_FQ_NAME) return
val index = (arg.symbol as? IrValueParameterSymbol)?.owner?.index ?: return
val genericOrAnyOverride = irFunction.overriddenSymbols.any {
+13
View File
@@ -0,0 +1,13 @@
// IGNORE_BACKEND: WASM, JS_IR
// IGNORE_BACKEND_FIR: JVM_IR
// FILE: result.kt
package kotlin
inline class Result(val value: Any?)
// FILE: box.kt
fun box(): String {
return Result("OK").value as String
}
@@ -16328,6 +16328,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt");
}
@Test
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@Test
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
@@ -16328,6 +16328,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt");
}
@Test
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@Test
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
@@ -14307,6 +14307,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt");
}
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt");
@@ -12247,6 +12247,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt");
}
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt");
@@ -12247,6 +12247,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt");
}
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt");
@@ -12312,6 +12312,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt");
}
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt");
@@ -6703,6 +6703,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/inlineClasses/referToUnderlyingPropertyOfInlineClass.kt");
}
@TestMetadata("result.kt")
public void testResult() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/result.kt");
}
@TestMetadata("resultInlining.kt")
public void testResultInlining() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt");