KT-958 wrong compilation of 'in' with complex expression under test
This commit is contained in:
@@ -1551,13 +1551,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
|
||||
private StackValue generateIn(JetBinaryExpression expression) {
|
||||
JetExpression expr = expression.getLeft();
|
||||
StackValue leftValue = gen(expr);
|
||||
if(isIntRangeExpr(expression.getRight())) {
|
||||
StackValue leftValue = StackValue.expression(Type.INT_TYPE, expression.getLeft(), this);
|
||||
JetBinaryExpression rangeExpression = (JetBinaryExpression) expression.getRight();
|
||||
boolean inverted = expression.getOperationReference().getReferencedNameElementType() == JetTokens.NOT_IN;
|
||||
getInIntRange(leftValue, rangeExpression, inverted);
|
||||
}
|
||||
else {
|
||||
StackValue leftValue = gen(expr);
|
||||
FunctionDescriptor op = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
|
||||
assert op != null;
|
||||
leftValue.put(asmType(op.getValueParameters().get(0).getOutType()), v);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun test() = 239
|
||||
|
||||
fun box() = if(test() in 239..240) "OK" else "fail"
|
||||
@@ -241,6 +241,11 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
// System.out.println(generateToText());
|
||||
}
|
||||
|
||||
public void testKt958() throws Exception {
|
||||
blackBoxFile("regressions/kt958.jet");
|
||||
// System.out.println(generateToText());
|
||||
}
|
||||
|
||||
public void testQuicksort() throws Exception {
|
||||
blackBoxFile("controlStructures/quicksort.jet");
|
||||
// System.out.println(generateToText());
|
||||
|
||||
Reference in New Issue
Block a user