KT-1199 - test and fix for erased case
This commit is contained in:
@@ -343,7 +343,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Type asmParamType = asmType(paramType);
|
Type asmParamType = asmType(paramType);
|
||||||
|
|
||||||
int iteratorVar = myFrameMap.enterTemp();
|
int iteratorVar = myFrameMap.enterTemp();
|
||||||
gen(expression.getLoopRange(), loopRangeType);
|
gen(expression.getLoopRange(), boxType(loopRangeType));
|
||||||
invokeFunctionNoParams(iteratorDescriptor, asmIterType, v);
|
invokeFunctionNoParams(iteratorDescriptor, asmIterType, v);
|
||||||
v.store(iteratorVar, asmIterType);
|
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");
|
blackBoxFile("regressions/kt873.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt1199 () {
|
||||||
|
blackBoxFile("regressions/kt1199.kt");
|
||||||
|
}
|
||||||
|
|
||||||
public void testFunction () throws InvocationTargetException, IllegalAccessException {
|
public void testFunction () throws InvocationTargetException, IllegalAccessException {
|
||||||
blackBoxFile("functions/functionExpression.jet");
|
blackBoxFile("functions/functionExpression.jet");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user