Fix for KT-15726: Kotlin can't compile nested try-catch with return
#KT-15726 Fixed
This commit is contained in:
+2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.optimization
|
||||
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.removeEmptyCatchBlocks
|
||||
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
|
||||
import org.jetbrains.org.objectweb.asm.Label
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
@@ -34,6 +35,7 @@ class LabelNormalizationMethodTransformer : MethodTransformer() {
|
||||
rewriteNonLabelInstructions()
|
||||
rewriteTryCatchBlocks()
|
||||
rewriteLocalVars()
|
||||
methodNode.removeEmptyCatchBlocks()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
fun nyCompiler() {
|
||||
try {
|
||||
return
|
||||
}
|
||||
catch (e: Exception) {}
|
||||
finally {
|
||||
try {} catch (e: Exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun nyCompiler2() {
|
||||
try {
|
||||
return
|
||||
}
|
||||
finally {
|
||||
try {} catch (e: Exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
nyCompiler()
|
||||
nyCompiler2()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@kotlin.Metadata
|
||||
public final class Kt15726Kt {
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static method nyCompiler(): void
|
||||
public final static method nyCompiler2(): void
|
||||
}
|
||||
+6
@@ -4103,6 +4103,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt15726.kt")
|
||||
public void testKt15726() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt15726.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1688.kt")
|
||||
public void testKt1688() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt1688.kt");
|
||||
|
||||
@@ -4103,6 +4103,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt15726.kt")
|
||||
public void testKt15726() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt15726.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1688.kt")
|
||||
public void testKt1688() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt1688.kt");
|
||||
|
||||
@@ -4103,6 +4103,12 @@ public class LightAnalysisModeCodegenTestGenerated extends AbstractLightAnalysis
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt15726.kt")
|
||||
public void testKt15726() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt15726.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1688.kt")
|
||||
public void testKt1688() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt1688.kt");
|
||||
|
||||
@@ -4752,6 +4752,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt15726.kt")
|
||||
public void testKt15726() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt15726.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1688.kt")
|
||||
public void testKt1688() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/kt1688.kt");
|
||||
|
||||
Reference in New Issue
Block a user