提交 cd189c08 编写于 作者: I Ilmir Usmanov

JVM_IR. Do not unbox Result in inline lambda

Since JVM_IR generates inline lambdas differently from old backend,
in this case, it generates them as normal functions.
Thus, there is no need to unbox the lambda argument.
 #KT-44671 Fixed
上级 fb296b5b
...@@ -10685,6 +10685,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT ...@@ -10685,6 +10685,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt");
} }
@Test
@TestMetadata("resultExceptionOrNullInLambda.kt")
public void testResultExceptionOrNullInLambda() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/resultExceptionOrNullInLambda.kt");
}
@Test @Test
@TestMetadata("startCoroutine.kt") @TestMetadata("startCoroutine.kt")
public void testStartCoroutine() throws Exception { public void testStartCoroutine() throws Exception {
...@@ -626,6 +626,7 @@ class ExpressionCodegen( ...@@ -626,6 +626,7 @@ class ExpressionCodegen(
// bridge to unbox it. Instead, we unbox it in the non-mangled function manually. // bridge to unbox it. Instead, we unbox it in the non-mangled function manually.
private fun unboxResultIfNeeded(arg: IrGetValue) { private fun unboxResultIfNeeded(arg: IrGetValue) {
if (arg.type.erasedUpperBound.fqNameWhenAvailable != StandardNames.RESULT_FQ_NAME) return if (arg.type.erasedUpperBound.fqNameWhenAvailable != StandardNames.RESULT_FQ_NAME) return
if (irFunction.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) return
if (!onlyResultInlineClassParameters()) return if (!onlyResultInlineClassParameters()) return
if (irFunction !is IrSimpleFunction) return if (irFunction !is IrSimpleFunction) return
// Skip Result's methods // Skip Result's methods
......
// WITH_RUNTIME
import kotlin.coroutines.intrinsics.*
import kotlin.coroutines.*
fun myRun(c: () -> Unit) {
c()
}
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
fun box(): String {
var contiuation: Continuation<Unit>? = null
val c: suspend () -> Unit = {
suspendCoroutine {
contiuation = it
}
}
var exception: Throwable? = null
myRun {
c.startCoroutineUninterceptedOrReturn(Continuation(EmptyCoroutineContext) {
exception = it.exceptionOrNull()
})
}
contiuation?.resumeWithException(RuntimeException("OK"))
return exception!!.message!!
}
\ No newline at end of file
...@@ -10685,6 +10685,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { ...@@ -10685,6 +10685,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt");
} }
@Test
@TestMetadata("resultExceptionOrNullInLambda.kt")
public void testResultExceptionOrNullInLambda() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/resultExceptionOrNullInLambda.kt");
}
@Test @Test
@TestMetadata("startCoroutine.kt") @TestMetadata("startCoroutine.kt")
public void testStartCoroutine() throws Exception { public void testStartCoroutine() throws Exception {
...@@ -10685,6 +10685,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes ...@@ -10685,6 +10685,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt");
} }
@Test
@TestMetadata("resultExceptionOrNullInLambda.kt")
public void testResultExceptionOrNullInLambda() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/resultExceptionOrNullInLambda.kt");
}
@Test @Test
@TestMetadata("startCoroutine.kt") @TestMetadata("startCoroutine.kt")
public void testStartCoroutine() throws Exception { public void testStartCoroutine() throws Exception {
...@@ -8558,6 +8558,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes ...@@ -8558,6 +8558,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt");
} }
@TestMetadata("resultExceptionOrNullInLambda.kt")
public void testResultExceptionOrNullInLambda() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/resultExceptionOrNullInLambda.kt");
}
@TestMetadata("startCoroutine.kt") @TestMetadata("startCoroutine.kt")
public void testStartCoroutine() throws Exception { public void testStartCoroutine() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt");
...@@ -7668,6 +7668,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes ...@@ -7668,6 +7668,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt");
} }
@TestMetadata("resultExceptionOrNullInLambda.kt")
public void testResultExceptionOrNullInLambda() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/resultExceptionOrNullInLambda.kt");
}
@TestMetadata("startCoroutine.kt") @TestMetadata("startCoroutine.kt")
public void testStartCoroutine() throws Exception { public void testStartCoroutine() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt");
...@@ -7153,6 +7153,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { ...@@ -7153,6 +7153,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt");
} }
@TestMetadata("resultExceptionOrNullInLambda.kt")
public void testResultExceptionOrNullInLambda() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/resultExceptionOrNullInLambda.kt");
}
@TestMetadata("startCoroutine.kt") @TestMetadata("startCoroutine.kt")
public void testStartCoroutine() throws Exception { public void testStartCoroutine() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt");
...@@ -7153,6 +7153,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { ...@@ -7153,6 +7153,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt");
} }
@TestMetadata("resultExceptionOrNullInLambda.kt")
public void testResultExceptionOrNullInLambda() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/resultExceptionOrNullInLambda.kt");
}
@TestMetadata("startCoroutine.kt") @TestMetadata("startCoroutine.kt")
public void testStartCoroutine() throws Exception { public void testStartCoroutine() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt"); runTest("compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册