DfaFactType: fixed default range for float/double; tests

Fixes test DataFlowRangeAnalysisTest.testLongRangeBasics
This commit is contained in:
Tagir Valeev
2017-10-06 11:38:50 +07:00
parent 916015a093
commit 1ad304b30c
2 changed files with 13 additions and 2 deletions
@@ -114,9 +114,8 @@ public abstract class DfaFactType<T> extends Key<T> {
}
}
PsiModifierListOwner psiVariable = var.getPsiVariable();
LongRangeSet fromAnnotation = LongRangeSet.fromAnnotation(psiVariable);
LongRangeSet fromType = LongRangeSet.fromType(var.getVariableType());
return fromType == null ? fromAnnotation : fromAnnotation.intersect(fromType);
return fromType == null ? null : LongRangeSet.fromAnnotation(psiVariable).intersect(fromType);
}
@Nullable
@@ -6,6 +6,18 @@ public class LongRangeAnnotation {
return new Random().nextInt(100);
}
@Nonnegative int x;
@Nonnegative double y;
void testField() {
if(<warning descr="Condition 'x < 0' is always 'false'">x < 0</warning>) {
System.out.println("Impossible");
}
if(y < 0) {
System.out.println("Doubles are not supported yet");
}
}
void testAnnotated() {
int value = method();
if(value == 0) {