Some fixes for try...finally
This commit is contained in:
@@ -275,9 +275,15 @@ public class JetControlFlowProcessor {
|
|||||||
final JetFinallySection finallyBlock = expression.getFinallyBlock();
|
final JetFinallySection finallyBlock = expression.getFinallyBlock();
|
||||||
if (finallyBlock != null) {
|
if (finallyBlock != null) {
|
||||||
builder.enterTryFinally(new GenerationTrigger() {
|
builder.enterTryFinally(new GenerationTrigger() {
|
||||||
|
private boolean working = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate() {
|
public void generate() {
|
||||||
|
// This checks are needed for the case of having e.g. return inside finally: 'try {return} finally{return}'
|
||||||
|
if (working) return;
|
||||||
|
working = true;
|
||||||
value(finallyBlock.getFinalExpression(), true, inCondition);
|
value(finallyBlock.getFinalExpression(), true, inCondition);
|
||||||
|
working = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -290,6 +290,10 @@ public class TopDownAnalyzer {
|
|||||||
// This is needed in order to highlight only '1 < 2' and not '1', '<' and '2' as well
|
// This is needed in order to highlight only '1 < 2' and not '1', '<' and '2' as well
|
||||||
Set<JetElement> rootElements = findRootExpressions(unreachableElements);
|
Set<JetElement> rootElements = findRootExpressions(unreachableElements);
|
||||||
|
|
||||||
|
// TODO : (return 1) || (return 2) -- only || and right of it is unreachable
|
||||||
|
// TODO : try {return 1} finally {return 2}. Currently 'return 1' is reported as unreachable,
|
||||||
|
// though it'd better be reported more specifically
|
||||||
|
|
||||||
for (JetElement element : rootElements) {
|
for (JetElement element : rootElements) {
|
||||||
semanticServices.getErrorHandler().genericError(element.getNode(), "Unreachable code");
|
semanticServices.getErrorHandler().genericError(element.getNode(), "Unreachable code");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,3 +123,11 @@ fun t3(a : Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun tf() {
|
||||||
|
try {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,3 +129,8 @@ fun blockAndAndMismatch() : Boolean {
|
|||||||
<error>(return true) || (return false)</error>
|
<error>(return true) || (return false)</error>
|
||||||
<error>1</error>
|
<error>1</error>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun tf() {
|
||||||
|
try {return} finally{return}
|
||||||
|
<error>1</error>
|
||||||
|
}
|
||||||
@@ -58,7 +58,7 @@ public class JetControlFlowTest extends JetTestCaseBase {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AnalyzingUtils.analyzeNamespace(file.getRootNamespace(), ErrorHandler.THROW_EXCEPTION, new JetControlFlowDataTraceFactory() {
|
AnalyzingUtils.analyzeNamespace(file.getRootNamespace(), ErrorHandler.DO_NOTHING, new JetControlFlowDataTraceFactory() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public JetPseudocodeTrace createTrace(JetElement element) {
|
public JetPseudocodeTrace createTrace(JetElement element) {
|
||||||
|
|||||||
Reference in New Issue
Block a user