Fix for finally before empty return
This commit is contained in:
@@ -1332,6 +1332,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
v.areturn(returnType);
|
v.areturn(returnType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
doFinallyOnReturn();
|
||||||
v.visitInsn(RETURN);
|
v.visitInsn(RETURN);
|
||||||
}
|
}
|
||||||
return StackValue.none();
|
return StackValue.none();
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
var result = "Fail"
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
try {
|
||||||
|
return
|
||||||
|
} finally {
|
||||||
|
result = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
foo()
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -469,4 +469,9 @@ public class ControlStructuresTest extends CodegenTestCase {
|
|||||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||||
blackBoxFile("controlStructures/conditionOfEmptyIf.kt");
|
blackBoxFile("controlStructures/conditionOfEmptyIf.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFinallyOnEmptyReturn() {
|
||||||
|
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||||
|
blackBoxFile("controlStructures/finallyOnEmptyReturn.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user