generating the body of the finally clause _four_ times is one time too many
#KT-1688 Fixed
This commit is contained in:
@@ -948,7 +948,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
}
|
||||
|
||||
private void doFinallyOnReturnOrThrow() {
|
||||
private void doFinallyOnReturn() {
|
||||
for(int i = blockStackElements.size()-1; i >= 0; --i) {
|
||||
BlockStackElement stackElement = blockStackElements.get(i);
|
||||
if(stackElement instanceof FinallyBlockStackElement) {
|
||||
@@ -969,7 +969,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
final JetExpression returnedExpression = expression.getReturnedExpression();
|
||||
if (returnedExpression != null) {
|
||||
gen(returnedExpression, returnType);
|
||||
doFinallyOnReturnOrThrow();
|
||||
doFinallyOnReturn();
|
||||
v.areturn(returnType);
|
||||
}
|
||||
else {
|
||||
@@ -2648,7 +2648,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
@Override
|
||||
public StackValue visitThrowExpression(JetThrowExpression expression, StackValue receiver) {
|
||||
gen(expression.getThrownExpression(), TYPE_THROWABLE);
|
||||
doFinallyOnReturnOrThrow();
|
||||
v.athrow();
|
||||
return StackValue.none();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
var s = ""
|
||||
try {
|
||||
throw RuntimeException()
|
||||
} catch (e : RuntimeException) {
|
||||
} finally {
|
||||
s += "OK"
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -337,17 +337,17 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
blackBoxFile("regressions/kt2147.kt");
|
||||
}
|
||||
|
||||
public void testIfDummy() throws Exception {
|
||||
public void testIfDummy() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||
blackBoxFile("regressions/kt1899.kt");
|
||||
}
|
||||
|
||||
public void testKt1742() throws Exception {
|
||||
public void testKt1742() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||
blackBoxFile("regressions/kt1742.kt");
|
||||
}
|
||||
|
||||
public void testKt2062() throws Exception {
|
||||
public void testKt2062() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||
blackBoxFile("regressions/kt2062.kt");
|
||||
}
|
||||
@@ -356,4 +356,9 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||
blackBoxFile("regressions/kt910.kt");
|
||||
}
|
||||
|
||||
public void testKt1688() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||
blackBoxFile("regressions/kt1688.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user