diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt index e1c8428bab8..4110c690ea8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt @@ -1329,7 +1329,7 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction: variable.desc, variable.signature, variable.start, - nextSuspensionPointStartLabel(variable.start), + min(variable.end, nextSuspensionPointStartLabel(variable.start)), variable.index ) ) 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 708a1c70a5d..b961880f481 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 @@ -10849,6 +10849,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); } + @Test + @TestMetadata("unusedCatchVar.kt") + public void testUnusedCatchVar() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt"); + } + @Test @TestMetadata("usedInArrayStore.kt") public void testUsedInArrayStore() throws Exception { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt new file mode 100644 index 00000000000..49ee006bb68 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt @@ -0,0 +1,23 @@ +// WITH_RUNTIME +// WITH_COROUTINES +// FULL_RUNTIME +// KJS_WITH_FULL_RUNTIME + +class JarFile { + fun entries() = listOf() +} + +private fun scriptTemplatesDiscoverySequence(): Sequence { + return sequence { + yield("OK") + for (dep in listOf()) { + try { + } catch (e: Throwable) { + } + } + } +} + +fun box(): String { + return scriptTemplatesDiscoverySequence().first() +} 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 879300842fb..372f9d4805c 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 @@ -10849,6 +10849,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); } + @Test + @TestMetadata("unusedCatchVar.kt") + public void testUnusedCatchVar() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt"); + } + @Test @TestMetadata("usedInArrayStore.kt") public void testUsedInArrayStore() 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 d7098734a47..f9cd7d6d9dd 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 @@ -10849,6 +10849,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); } + @Test + @TestMetadata("unusedCatchVar.kt") + public void testUnusedCatchVar() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt"); + } + @Test @TestMetadata("usedInArrayStore.kt") public void testUsedInArrayStore() 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 5da2e319333..a2d4e440d58 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -8630,6 +8630,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); } + @TestMetadata("unusedCatchVar.kt") + public void testUnusedCatchVar() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt"); + } + @TestMetadata("usedInArrayStore.kt") public void testUsedInArrayStore() throws Exception { runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.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 04a9585549c..44b617dbb73 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 @@ -7789,6 +7789,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); } + @TestMetadata("unusedCatchVar.kt") + public void testUnusedCatchVar() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt"); + } + @TestMetadata("usedInMethodCall.kt") public void testUsedInMethodCall() throws Exception { runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.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 72b0968fdbf..3cd5090e4c0 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 @@ -7210,6 +7210,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); } + @TestMetadata("unusedCatchVar.kt") + public void testUnusedCatchVar() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt"); + } + @TestMetadata("usedInMethodCall.kt") public void testUsedInMethodCall() throws Exception { runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.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 a957b09e334..b4eb968e992 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 @@ -7210,6 +7210,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); } + @TestMetadata("unusedCatchVar.kt") + public void testUnusedCatchVar() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/unusedCatchVar.kt"); + } + @TestMetadata("usedInMethodCall.kt") public void testUsedInMethodCall() throws Exception { runTest("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt");