mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PointlessArithmeticExpression: do not report if multiplication by 1.0 is used to cast.
GitOrigin-RevId: 8a24b3877998651ce031415d0ad68ef1e3f36c7a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fcf1ee68b5
commit
2c499916f6
+3
-1
@@ -40,6 +40,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -230,7 +231,8 @@ public class PointlessArithmeticExpressionInspection extends BaseInspection {
|
||||
isOne(expressions[1]);
|
||||
}
|
||||
if (type.equals(JavaTokenType.ASTERISK)) {
|
||||
return isOne(expressions[0]) || isOne(expressions[1]);
|
||||
return (isOne(expressions[0]) || isOne(expressions[1])) &&
|
||||
Objects.requireNonNull(expressions[0].getType()).equals(expressions[1].getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+4
@@ -173,4 +173,8 @@ class FloatingPoint {
|
||||
float res7 = x * 0.0f;
|
||||
float res8 = 0.0f / x;
|
||||
}
|
||||
|
||||
void multiplyToCast(int x, int y) {
|
||||
double xyz = (1.0 * x) / y;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user