EA-39177 - CCE: ArrayIterator.generate

If local variable is auto-casted to array, it should be iterated as array.
This commit is contained in:
Evgeny Gerashchenko
2012-09-13 23:24:58 +04:00
parent 2f89352d80
commit c33b880a57
4 changed files with 20 additions and 3 deletions
@@ -680,8 +680,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetExpression loopRange = forExpression.getLoopRange();
StackValue value = gen(loopRange);
if (value instanceof StackValue.Local) {
arrayVar = ((StackValue.Local) value).index;
Type asmLoopRangeType = asmType(loopRangeType);
if (value instanceof StackValue.Local && value.type.equals(asmLoopRangeType)) {
arrayVar = ((StackValue.Local) value).index; // no need to copy local variable into another variable
}
else {
arrayVar = myFrameMap.enterTemp(OBJECT_TYPE);
@@ -691,7 +692,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
myFrameMap.leaveTemp(OBJECT_TYPE);
}
};
Type asmLoopRangeType = asmType(loopRangeType);
value.put(asmLoopRangeType, v);
v.store(arrayVar, OBJECT_TYPE);
}