KT-711 primitive value in left side of elvis operator

This commit is contained in:
Alex Tkachman
2011-12-03 18:22:18 +02:00
parent cd635121ea
commit d33d1367de
2 changed files with 12 additions and 0 deletions
@@ -1693,6 +1693,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
final Type exprType = expressionType(expression);
final Type leftType = expressionType(expression.getLeft());
gen(expression.getLeft(), leftType);
if(leftType.getSort() != Type.OBJECT && leftType.getSort() != Type.ARRAY) {
if(leftType != exprType) {
StackValue.onStack(leftType).put(exprType, v);
}
return StackValue.onStack(exprType);
}
v.dup();
Label end = new Label();
Label ifNull = new Label();
@@ -285,6 +285,12 @@ public class PrimitiveTypesTest extends CodegenTestCase {
blackBoxFile("regressions/kt518.jet");
}
public void testKt711 () throws Exception {
loadText("fun box() = if ((1 ?: 0) == 1) \"OK\" else \"fail\"");
// System.out.println(generateToText());
blackBox();
}
public void testKt665() throws Exception {
loadText("fun f(x: Long, zzz: Long = 1): Long\n" +
"{\n" +