diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index e6a796be2d3..5d299c29eea 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -8790,6 +8790,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt"); } + @Test + @TestMetadata("castWithSuspend.kt") + public void testCastWithSuspend() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/castWithSuspend.kt"); + } + @Test @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend() throws Exception { diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt index f5117107a2b..bdce3f4c724 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt @@ -81,7 +81,7 @@ class MultipleCatchesLowering(private val context: JsIrBackendContext) : BodyLow } val catchBody = catch.result.transform(object : IrElementTransformer { - override fun visitGetValue(expression: IrGetValue, data: IrValueSymbol) = + override fun visitGetValue(expression: IrGetValue, data: IrValueSymbol): IrExpression = if (expression.symbol == data) castedPendingException() else diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt index f23ff69a9fe..ece1946e6ca 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt @@ -66,7 +66,7 @@ enum class IrTypeOperator { REINTERPRET_CAST; } -abstract class IrTypeOperatorCall : IrExpression() { +abstract class IrTypeOperatorCall : IrExpression(), IrExpressionWithCopy { abstract val operator: IrTypeOperator abstract var argument: IrExpression abstract var typeOperand: IrType diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt index 3f12c0a8e82..fdcd97351b0 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt @@ -46,4 +46,14 @@ class IrTypeOperatorCallImpl( override fun transformChildren(transformer: IrElementTransformer, data: D) { argument = argument.transform(transformer, data) } + + override fun copy(): IrExpression = + IrTypeOperatorCallImpl( + startOffset, + endOffset, + type, + operator, + typeOperand, + argument + ) } diff --git a/compiler/testData/codegen/box/coroutines/castWithSuspend.kt b/compiler/testData/codegen/box/coroutines/castWithSuspend.kt new file mode 100644 index 00000000000..3fa459cb7af --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/castWithSuspend.kt @@ -0,0 +1,21 @@ +// KJS_WITH_FULL_RUNTIME +// WITH_RUNTIME +// WITH_COROUTINES + +import kotlin.coroutines.intrinsics.* + +suspend fun foo() { + DeferredCoroutine().await() +} + +class DeferredCoroutine { + suspend fun await(): T = awaitInternal() as T +} + +internal suspend fun awaitInternal(): Any? = suspendCoroutineUninterceptedOrReturn { uCont -> + +} + +fun box(): String { + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index d7ac6dc1e02..b6b1e1c1fec 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -8790,6 +8790,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt"); } + @Test + @TestMetadata("castWithSuspend.kt") + public void testCastWithSuspend() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/castWithSuspend.kt"); + } + @Test @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 4754704f82e..bffe27a6ab4 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -8790,6 +8790,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt"); } + @Test + @TestMetadata("castWithSuspend.kt") + public void testCastWithSuspend() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/castWithSuspend.kt"); + } + @Test @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 596662e8e12..077416bf558 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -6854,6 +6854,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt"); } + @TestMetadata("castWithSuspend.kt") + public void testCastWithSuspend() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/castWithSuspend.kt"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend() throws Exception { runTest("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 4a0d5f97df0..c4d25f0556c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -6118,6 +6118,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt"); } + @TestMetadata("castWithSuspend.kt") + public void testCastWithSuspend() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/castWithSuspend.kt"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend() throws Exception { runTest("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index b73f72f9bc4..fb5c8f8902d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -5539,6 +5539,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt"); } + @TestMetadata("castWithSuspend.kt") + public void testCastWithSuspend() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/castWithSuspend.kt"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend() throws Exception { runTest("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 4682ba560e9..84f00c049c4 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -5539,6 +5539,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt"); } + @TestMetadata("castWithSuspend.kt") + public void testCastWithSuspend() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/castWithSuspend.kt"); + } + @TestMetadata("catchWithInlineInsideSuspend.kt") public void testCatchWithInlineInsideSuspend() throws Exception { runTest("compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt");