Support codegen of empty while-loop
#KT-3009 In Progress
This commit is contained in:
@@ -425,7 +425,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
StackValue conditionValue = gen(expression.getCondition());
|
||||
conditionValue.condJump(end, true, v);
|
||||
|
||||
gen(expression.getBody(), Type.VOID_TYPE);
|
||||
JetExpression body = expression.getBody();
|
||||
if (body != null) {
|
||||
gen(body, Type.VOID_TYPE);
|
||||
}
|
||||
|
||||
v.goTo(condition);
|
||||
|
||||
v.mark(end);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fun box(): String {
|
||||
while (false);
|
||||
|
||||
var x = 0
|
||||
while (x++<5);
|
||||
if (x != 6) return "Fail: $x"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1432,6 +1432,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/controlStructures/emptyIf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyWhile.kt")
|
||||
public void testEmptyWhile() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/controlStructures/emptyWhile.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("finallyOnEmptyReturn.kt")
|
||||
public void testFinallyOnEmptyReturn() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/controlStructures/finallyOnEmptyReturn.kt");
|
||||
|
||||
Reference in New Issue
Block a user