IntRange iteration calls correct methods on IntRange class

This commit is contained in:
Dmitry Jemerov
2011-10-19 20:29:55 +02:00
parent bfbc7ad601
commit c26ab4b472
4 changed files with 20 additions and 5 deletions
@@ -429,9 +429,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
gen(expression.getLoopRange(), loopRangeType);
v.dup();
v.invokevirtual("jet/IntRange", "getStartValue", "()I");
v.invokevirtual("jet/IntRange", "getStart", "()I");
v.store(lookupLocal(parameterDescriptor), Type.INT_TYPE);
v.invokevirtual("jet/IntRange", "getEndValue", "()I");
v.invokevirtual("jet/IntRange", "getEnd", "()I");
v.store(myEndVar, Type.INT_TYPE);
}
}
@@ -0,0 +1,13 @@
fun box() : String {
val a = Array<String?>(3)
a[0] = "a"
a[1] = "b"
a[2] = "c"
val result = 0
for(i in a.indices) {
result += i
}
if (result != 3) return "FAIL"
return "OK"
}
@@ -63,7 +63,7 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
throw new UnsupportedOperationException();
}
protected void blackBoxFile(String filename) throws Exception {
protected void blackBoxFile(String filename) {
loadFile(filename);
String actual;
try {
@@ -1,7 +1,5 @@
package org.jetbrains.jet.codegen;
import jet.typeinfo.TypeInfo;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
@@ -169,6 +167,10 @@ public class ControlStructuresTest extends CodegenTestCase {
blackBoxFile("controlStructures/forNullableIntArray.jet");
}
public void testForIntRange() {
blackBoxFile("controlStructures/forIntRange.jet");
}
public void testKt237() throws Exception {
blackBoxFile("regressions/kt237.jet");
}