fix for KT-299

This commit is contained in:
Alex Tkachman
2011-09-12 18:01:39 +03:00
parent 4071d67c41
commit b7542ecc4e
3 changed files with 23 additions and 2 deletions
@@ -1196,10 +1196,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
getInIntRange(leftValue, rangeExpression, inverted);
}
else {
leftValue.put(JetTypeMapper.TYPE_OBJECT, v);
FunctionDescriptor op = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
leftValue.put(typeMapper.mapType(op.getValueParameters().get(0).getOutType()), v);
genToJVMStack(expression.getRight());
v.swap();
FunctionDescriptor op = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
invokeFunctionNoParams(op, Type.BOOLEAN_TYPE, v);
}
return StackValue.onStack(Type.BOOLEAN_TYPE);
@@ -0,0 +1,17 @@
class MyRange1() : Range<Int> {
override fun contains(item: Int) = true
}
class MyRange2() {
fun contains(item: Int) = true
}
fun box(): String {
if (1 in MyRange1()) {
if (1 in MyRange2()) {
return "OK"
}
return "fail 2"
}
return "fail 1"
}
@@ -177,4 +177,8 @@ public class ControlStructuresTest extends CodegenTestCase {
assertEquals(true, main.invoke(null, null, "lala"));
assertEquals(false, main.invoke(null, "papa", "papa"));
}
public void testKt299() throws Exception {
blackBoxFile("regressions/kt299.jet");
}
}