Write proper start label for loop parameter
This commit is contained in:
@@ -627,7 +627,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
// for (e : E in c) {...}
|
||||
protected final KtForExpression forExpression;
|
||||
private final Label bodyStart = new Label();
|
||||
private final Label loopParameterStartLabel = new Label();
|
||||
private final Label bodyEnd = new Label();
|
||||
private final List<Runnable> leaveVariableTasks = Lists.newArrayList();
|
||||
|
||||
@@ -667,7 +667,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
myFrameMap.leave(parameterDescriptor);
|
||||
v.visitLocalVariable(parameterDescriptor.getName().asString(),
|
||||
loopParameterType.getDescriptor(), null,
|
||||
bodyStart, bodyEnd,
|
||||
loopParameterStartLabel, bodyEnd,
|
||||
loopParameterVar);
|
||||
}
|
||||
});
|
||||
@@ -687,9 +687,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
public abstract void checkPreCondition(@NotNull Label loopExit);
|
||||
|
||||
public void beforeBody() {
|
||||
v.mark(bodyStart);
|
||||
|
||||
assignToLoopParameter();
|
||||
v.mark(loopParameterStartLabel);
|
||||
|
||||
if (forExpression.getLoopParameter() == null) {
|
||||
KtDestructuringDeclaration multiParameter = forExpression.getDestructuringParameter();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fun f() {
|
||||
for (c in "123") {
|
||||
print(c)
|
||||
}
|
||||
}
|
||||
|
||||
// 1 ISTORE 0\s+L3
|
||||
// 1 ILOAD 0\s+INVOKEVIRTUAL java/io/PrintStream.print \(C\)V
|
||||
// 1 LOCALVARIABLE c C L3 L8 0
|
||||
@@ -835,6 +835,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/forLoop"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("loopVarInterval.kt")
|
||||
public void testLoopVarInterval() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/loopVarInterval.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveLiteralRange1.kt")
|
||||
public void testPrimitiveLiteralRange1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1.kt");
|
||||
|
||||
Reference in New Issue
Block a user