KT-1199 - test and fix for erased case

This commit is contained in:
Alex Tkachman
2012-02-11 11:09:02 +02:00
parent a9e1eb3615
commit 8d9434548f
3 changed files with 25 additions and 1 deletions
@@ -343,7 +343,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
Type asmParamType = asmType(paramType);
int iteratorVar = myFrameMap.enterTemp();
gen(expression.getLoopRange(), loopRangeType);
gen(expression.getLoopRange(), boxType(loopRangeType));
invokeFunctionNoParams(iteratorDescriptor, asmIterType, v);
v.store(iteratorVar, asmIterType);
@@ -0,0 +1,20 @@
fun <erased T : Any> T?.iterator() = object {
var hasNext = this@iterator != null
private set
fun next() : T {
if (hasNext) {
hasNext = false
return this@iterator.sure()
}
throw java.util.NoSuchElementException()
}
}
fun box() : String {
var k = 0
for (i in 1) {
k++
}
return if(k == 1) "OK" else "fail"
}
@@ -70,6 +70,10 @@ public class FunctionGenTest extends CodegenTestCase {
blackBoxFile("regressions/kt873.kt");
}
public void testKt1199 () {
blackBoxFile("regressions/kt1199.kt");
}
public void testFunction () throws InvocationTargetException, IllegalAccessException {
blackBoxFile("functions/functionExpression.jet");
}