Support codegen of empty for-loop
#KT-3009 Fixed EA-35742 fixed
This commit is contained in:
@@ -652,7 +652,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
protected abstract void increment(@NotNull Label loopExit);
|
||||
|
||||
public void body() {
|
||||
gen(forExpression.getBody(), Type.VOID_TYPE);
|
||||
JetExpression body = forExpression.getBody();
|
||||
if (body != null) {
|
||||
gen(body, Type.VOID_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleLeaveVariable(Runnable runnable) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
var index = 0
|
||||
|
||||
val iterator = object : Iterator<Int> {
|
||||
override fun hasNext() = index < 5
|
||||
override fun next() = index++
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
for (x in 1..5);
|
||||
|
||||
for (x in iterator);
|
||||
if (index != 5) return "Fail: $index"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1432,6 +1432,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/controlStructures/emptyDoWhile.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyFor.kt")
|
||||
public void testEmptyFor() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/controlStructures/emptyFor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyIf.kt")
|
||||
public void testEmptyIf() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/controlStructures/emptyIf.kt");
|
||||
|
||||
Reference in New Issue
Block a user