KT-27948: Use proper KotlinType when comparing with literal 0

#KT-27948
This commit is contained in:
Dmitry Petrov
2018-11-07 12:34:45 +03:00
parent e14f74bc18
commit 1523185734
8 changed files with 76 additions and 1 deletions
@@ -3680,8 +3680,17 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
private StackValue genCmpWithZero(KtExpression exp, IElementType opToken, @Nullable StackValue pregeneratedExpr) {
StackValue argument;
if (pregeneratedExpr == null) {
KotlinType kotlinType = kotlinType(exp);
assert kotlinType != null : "No KotlinType for expression " + exp.getText();
argument = genLazy(exp, asmType(kotlinType), kotlinType);
}
else {
argument = pregeneratedExpr;
}
return StackValue.compareIntWithZero(
pregeneratedExpr != null ? pregeneratedExpr : gen(exp),
argument,
(KtTokens.EQEQ == opToken || KtTokens.EQEQEQ == opToken) ? IFNE : IFEQ
);
}