Fix wrong checkcast for === on objects

#KT-6747 Fixed
This commit is contained in:
Alexander Udalov
2015-02-11 03:07:57 +03:00
parent 37ec103d6a
commit a280599969
5 changed files with 33 additions and 12 deletions
@@ -527,10 +527,6 @@ public class AsmUtil {
return StackValue.cmp(opToken, leftType, left, right);
}
if (opToken == JetTokens.EQEQEQ || opToken == JetTokens.EXCLEQEQEQ) {
return StackValue.cmp(opToken, leftType, left, right);
}
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
@@ -3056,7 +3056,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
rightType = boxType(rightType);
}
return genEqualsForExpressionsOnStack(opToken, genLazy(left, leftType), genLazy(right, rightType));
StackValue leftValue = genLazy(left, leftType);
StackValue rightValue = genLazy(right, rightType);
if (opToken == JetTokens.EQEQEQ || opToken == JetTokens.EXCLEQEQEQ) {
// TODO: always casting to the type of the left operand in case of primitives looks wrong
Type operandType = isPrimitive(leftType) ? leftType : OBJECT_TYPE;
return StackValue.cmp(opToken, operandType, leftValue, rightValue);
}
return genEqualsForExpressionsOnStack(opToken, leftValue, rightValue);
}
private boolean isIntZero(JetExpression expr, Type exprType) {