mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-246334 Dataflow to here: filtering long variable with <= 0 yields no results.
GitOrigin-RevId: 80981136f8e8541d4c5b872ccf851de9e550aa72
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c1c03744ac
commit
5c63dd413a
@@ -53,9 +53,10 @@ final class DfaBasedFilter {
|
||||
|
||||
private boolean allowed(@NotNull PsiElement element, boolean assertionsDisabled) {
|
||||
if (myDfType instanceof DfConstantType && element instanceof PsiLiteralValue) {
|
||||
Object constValue = ((DfConstantType<?>)myDfType).getValue();
|
||||
DfConstantType<?> dfConstantType = (DfConstantType<?>)myDfType;
|
||||
Object constValue = dfConstantType.getValue();
|
||||
if (!(constValue instanceof PsiElement)) {
|
||||
Object value = ((PsiLiteralValue)element).getValue();
|
||||
Object value = TypeConversionUtil.computeCastTo(((PsiLiteralValue)element).getValue(), dfConstantType.getPsiType());
|
||||
return Objects.equals(value, constValue);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +88,12 @@ final class DfaBasedFilter {
|
||||
CommonDataflow.DataflowResult result = CommonDataflow.getDataflowResult(expression);
|
||||
if (result == null) return DfTypes.TOP;
|
||||
expression = PsiUtil.skipParenthesizedExprDown(expression);
|
||||
return assertionsDisabled ? result.getDfTypeNoAssertions(expression) : result.getDfType(expression);
|
||||
DfType type = assertionsDisabled ? result.getDfTypeNoAssertions(expression) : result.getDfType(expression);
|
||||
if (myDfType instanceof DfLongType && type instanceof DfIntType) {
|
||||
// Implicit widening conversion
|
||||
return DfTypes.longRange(((DfIntType)type).getRange());
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
double x = <flown1>0;
|
||||
System.out.println(<caret>x);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
long x = <flown1>0;
|
||||
System.out.println(<caret>x);
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,8 @@ public class SliceBackwardTest extends SliceTestCase {
|
||||
public void testFilterPropagateBoolean2() throws Exception { doTest("false");}
|
||||
public void testFilterAssertionViolation() throws Exception { doTest("-1");}
|
||||
public void testReturnParameter() throws Exception { doTest(); }
|
||||
public void testFilterLongByInt() throws Exception { doTest("<=0"); }
|
||||
public void testFilterDoubleByInt() throws Exception { doTest("0.0"); }
|
||||
|
||||
public void testStackFilterSimple() throws Exception {
|
||||
doTest("null", "MainTest:test", "MainTest:foo", "MainTest:main");
|
||||
|
||||
Reference in New Issue
Block a user