Compare FP numbers properly when determining if field initializer needed

This commit is contained in:
Dmitry Petrov
2018-07-20 14:35:49 +03:00
parent 819ffe7117
commit 86e863951e
5 changed files with 32 additions and 2 deletions
@@ -578,10 +578,10 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
if (type == Type.SHORT_TYPE && ((Number) value).shortValue() == 0) {
return true;
}
if (type == Type.DOUBLE_TYPE && ((Number) value).doubleValue() == 0d) {
if (type == Type.DOUBLE_TYPE && value.equals(0.0)) {
return true;
}
if (type == Type.FLOAT_TYPE && ((Number) value).floatValue() == 0f) {
if (type == Type.FLOAT_TYPE && value.equals(0.0f)) {
return true;
}
}