mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Mark code like if(x > Double.NaN) as "always false"
Fixes part of IDEA-193102 x > Double.NaN comparison should be highlighted as always false
This commit is contained in:
+1
-4
@@ -441,10 +441,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
|||||||
|
|
||||||
|
|
||||||
private boolean isEffectivelyNaN(@NotNull DfaValue dfaValue) {
|
private boolean isEffectivelyNaN(@NotNull DfaValue dfaValue) {
|
||||||
for (DfaValue eqClass : getEquivalentValues(dfaValue)) {
|
return isNaN(dfaValue) || getEquivalentValues(dfaValue).stream().anyMatch(DfaMemoryStateImpl::isNaN);
|
||||||
if (isNaN(eqClass)) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<EqClass> getEqClasses() {
|
List<EqClass> getEqClasses() {
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
public class DoubleNaN {
|
public class DoubleNaN {
|
||||||
|
void testNanCmp(double x) {
|
||||||
|
if (<warning descr="Condition 'x > Double.NaN' is always 'false'">x > Double.NaN</warning>) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean cmp = x > Double.NaN; // this is always false, a warning is expected
|
||||||
|
System.out.println(x > Double.NaN); // this is always false, a warning is expected
|
||||||
|
}
|
||||||
|
|
||||||
void test() {
|
void test() {
|
||||||
double x = Double.NaN;
|
double x = Double.NaN;
|
||||||
double y = Double.NaN;
|
double y = Double.NaN;
|
||||||
|
|||||||
Reference in New Issue
Block a user