diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index eb2bd96d784..d3f56c7962a 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -268,7 +268,7 @@ public class ExpressionCodegen extends JetVisitor { Type asmIterType = typeMapper.boxType(typeMapper.mapType(iteratorType)); JetType paramType = parameterDescriptor.getOutType(); - Type asmParamType = typeMapper.boxType(typeMapper.mapType(paramType)); + Type asmParamType = typeMapper.mapType(paramType); int iteratorVar = myMap.enterTemp(); gen(expression.getLoopRange(), loopRangeType); diff --git a/idea/testData/codegen/controlStructures/forUserType.jet b/idea/testData/codegen/controlStructures/forUserType.jet index 24425da2c4e..cb070bb1c68 100644 --- a/idea/testData/codegen/controlStructures/forUserType.jet +++ b/idea/testData/codegen/controlStructures/forUserType.jet @@ -1,19 +1,26 @@ fun box() : String { + val c6 = MyCollection4() + for (el in c6) { + System.out?.println(el) + } + val c5 = MyCollection3() - for (el in c5) {} + for (el in c5) { + System.out?.println(el) + } val c1: java.lang.Iterable = MyCollection1() for (el in c1) {} val c2 = MyCollection1() for (el in c2) {} -/* + val c3: Iterable = MyCollection2() for (el in c3) {} val c4 = MyCollection2() for (el in c4) {} -*/ + return "OK" } @@ -39,7 +46,20 @@ class MyCollection3() { fun iterator() = MyIterator() class MyIterator() { - fun next() = 0 - fun hasNext() = false + var k : Int = 5 + + fun next() : Int? = k-- + fun hasNext() = k > 0 + } +} + +class MyCollection4() { + fun iterator() = MyIterator() + + class MyIterator() { + var k : Int = 5 + + fun next() : Int = k-- + fun hasNext() = k > 0 } }