Support Infinity and NaN in constant evaluator

This allows to store infinities and NaNs inside const vals
This commit is contained in:
Mikhail Zarechenskiy
2016-12-01 11:19:25 +03:00
parent 57964845ad
commit 25c3b43858
4 changed files with 67 additions and 11 deletions
@@ -455,7 +455,10 @@ private class ConstantExpressionEvaluatorVisitor(
if (isDivisionByZero(resultingDescriptorName.asString(), argumentForParameter.value)) {
val parentExpression: KtExpression = PsiTreeUtil.getParentOfType(receiverExpression, KtExpression::class.java)!!
trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression))
return factory.createErrorValue("Division by zero").wrap()
if (isIntegerType(argumentForReceiver.value) && isIntegerType(argumentForParameter.value)) {
return factory.createErrorValue("Division by zero").wrap()
}
}
val result = evaluateBinaryAndCheck(argumentForReceiver, argumentForParameter, resultingDescriptorName.asString(), callExpression) ?: return null