Fixed a bug in CF for when() expressions
This commit is contained in:
@@ -24,7 +24,7 @@ public interface JetControlFlowBuilder {
|
||||
void jumpOnFalse(@NotNull Label label);
|
||||
void jumpOnTrue(@NotNull Label label);
|
||||
void nondeterministicJump(Label label); // Maybe, jump to label
|
||||
void jumpToError(@NotNull JetThrowExpression expression);
|
||||
void jumpToError(JetThrowExpression expression);
|
||||
|
||||
// Entry/exit points
|
||||
Label getEntryPoint(@NotNull JetElement labelElement);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpToError(@NotNull JetThrowExpression expression) {
|
||||
public void jumpToError(JetThrowExpression expression) {
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
|
||||
|
||||
@@ -619,6 +619,8 @@ public class JetControlFlowProcessor {
|
||||
value(subjectExpression, false, inCondition);
|
||||
}
|
||||
|
||||
Label doneLabel = builder.createUnboundLabel();
|
||||
|
||||
Label nextLabel = builder.createUnboundLabel();
|
||||
for (JetWhenEntry whenEntry : expression.getEntries()) {
|
||||
if (whenEntry.getSubWhen() != null) throw new UnsupportedOperationException(); // TODO
|
||||
@@ -660,9 +662,12 @@ public class JetControlFlowProcessor {
|
||||
builder.nondeterministicJump(nextLabel);
|
||||
|
||||
value(whenEntry.getExpression(), true, inCondition);
|
||||
builder.jump(doneLabel);
|
||||
builder.bindLabel(nextLabel);
|
||||
nextLabel = builder.createUnboundLabel();
|
||||
}
|
||||
builder.jumpToError(null);
|
||||
builder.bindLabel(doneLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -244,7 +244,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpToError(@NotNull JetThrowExpression expression) {
|
||||
public void jumpToError(JetThrowExpression expression) {
|
||||
add(new UnconditionalJumpInstruction(error));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,4 +15,6 @@ fun foo() {
|
||||
<error>.</error>equals(1) => 1
|
||||
?.equals(1).equals(2) => 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo()
|
||||
Reference in New Issue
Block a user