correctly generate 'in' expressions with IntRange on RHS and a type other than Int on LHS

This commit is contained in:
Dmitry Jemerov
2015-03-04 19:45:49 +01:00
parent 1188be9070
commit 2835459920
3 changed files with 14 additions and 2 deletions
@@ -2906,7 +2906,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return generateElvis(expression);
}
else if (opToken == JetTokens.IN_KEYWORD || opToken == JetTokens.NOT_IN) {
return generateIn(StackValue.expression(Type.INT_TYPE, expression.getLeft(), this), expression.getRight(), reference);
return generateIn(StackValue.expression(expressionType(expression.getLeft()), expression.getLeft(), this),
expression.getRight(), reference);
}
else {
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
@@ -2935,7 +2936,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
if (isIntRangeExpr(deparenthesized)) {
if (isIntRangeExpr(deparenthesized) && AsmUtil.isIntPrimitive(leftValue.type)) {
genInIntRange(leftValue, (JetBinaryExpression) deparenthesized);
}
else {