fix for KT-245
This commit is contained in:
@@ -263,7 +263,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
final JetParameter loopParameter = expression.getLoopParameter();
|
||||
final VariableDescriptor parameterDescriptor = bindingContext.get(BindingContext.VALUE_PARAMETER, loopParameter);
|
||||
JetType paramType = parameterDescriptor.getOutType();
|
||||
Type asmParamType = typeMapper.mapType(paramType);
|
||||
Type asmParamType = typeMapper.boxType(typeMapper.mapType(paramType));
|
||||
|
||||
int iteratorVar = myMap.enterTemp();
|
||||
gen(expression.getLoopRange(), loopRangeType);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
fun foo() {
|
||||
val l = java.util.ArrayList<Int>(2)
|
||||
l.add(1)
|
||||
|
||||
for (el in l) {}
|
||||
|
||||
//verify error "Expecting to find integer on stack"
|
||||
val iterator = l.iterator()
|
||||
|
||||
//another verify error "Mismatched stack types"
|
||||
while (iterator?.hasNext() ?: false) {
|
||||
val i = iterator?.next()
|
||||
}
|
||||
|
||||
//the same
|
||||
if (iterator != null) {
|
||||
while (iterator.hasNext()) {
|
||||
val i = iterator?.next()
|
||||
}
|
||||
}
|
||||
|
||||
//this way it works
|
||||
if (iterator != null) {
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next() //because of the bug KT-244 i can't write "val i = iterator.next()"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
public class Kt247Test extends CodegenTestCase {
|
||||
public void testMe () throws Exception {
|
||||
blackBoxFile("regressions/kt247.jet");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
public class SafeRefTest extends CodegenTestCase {
|
||||
public void test247 () throws Exception {
|
||||
blackBoxFile("regressions/kt247.jet");
|
||||
}
|
||||
|
||||
public void test245 () throws Exception {
|
||||
blackBoxFile("regressions/kt245.jet");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user