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 jumpOnFalse(@NotNull Label label);
|
||||||
void jumpOnTrue(@NotNull Label label);
|
void jumpOnTrue(@NotNull Label label);
|
||||||
void nondeterministicJump(Label label); // Maybe, jump to label
|
void nondeterministicJump(Label label); // Maybe, jump to label
|
||||||
void jumpToError(@NotNull JetThrowExpression expression);
|
void jumpToError(JetThrowExpression expression);
|
||||||
|
|
||||||
// Entry/exit points
|
// Entry/exit points
|
||||||
Label getEntryPoint(@NotNull JetElement labelElement);
|
Label getEntryPoint(@NotNull JetElement labelElement);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void jumpToError(@NotNull JetThrowExpression expression) {
|
public void jumpToError(JetThrowExpression expression) {
|
||||||
builder.jumpToError(expression);
|
builder.jumpToError(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -619,6 +619,8 @@ public class JetControlFlowProcessor {
|
|||||||
value(subjectExpression, false, inCondition);
|
value(subjectExpression, false, inCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label doneLabel = builder.createUnboundLabel();
|
||||||
|
|
||||||
Label nextLabel = builder.createUnboundLabel();
|
Label nextLabel = builder.createUnboundLabel();
|
||||||
for (JetWhenEntry whenEntry : expression.getEntries()) {
|
for (JetWhenEntry whenEntry : expression.getEntries()) {
|
||||||
if (whenEntry.getSubWhen() != null) throw new UnsupportedOperationException(); // TODO
|
if (whenEntry.getSubWhen() != null) throw new UnsupportedOperationException(); // TODO
|
||||||
@@ -660,9 +662,12 @@ public class JetControlFlowProcessor {
|
|||||||
builder.nondeterministicJump(nextLabel);
|
builder.nondeterministicJump(nextLabel);
|
||||||
|
|
||||||
value(whenEntry.getExpression(), true, inCondition);
|
value(whenEntry.getExpression(), true, inCondition);
|
||||||
|
builder.jump(doneLabel);
|
||||||
builder.bindLabel(nextLabel);
|
builder.bindLabel(nextLabel);
|
||||||
nextLabel = builder.createUnboundLabel();
|
nextLabel = builder.createUnboundLabel();
|
||||||
}
|
}
|
||||||
|
builder.jumpToError(null);
|
||||||
|
builder.bindLabel(doneLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -244,7 +244,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void jumpToError(@NotNull JetThrowExpression expression) {
|
public void jumpToError(JetThrowExpression expression) {
|
||||||
add(new UnconditionalJumpInstruction(error));
|
add(new UnconditionalJumpInstruction(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,6 @@ fun foo() {
|
|||||||
<error>.</error>equals(1) => 1
|
<error>.</error>equals(1) => 1
|
||||||
?.equals(1).equals(2) => 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