mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DataFlowInspectionBase: do not report always-null for variables of java.lang.Void type
This commit is contained in:
+3
@@ -751,6 +751,9 @@ public class DataFlowInspectionBase extends AbstractBaseJavaLocalInspectionTool
|
||||
if (parent instanceof PsiBinaryExpression && ExpressionUtils.getValueComparedWithNull((PsiBinaryExpression)parent) != null) return true;
|
||||
// Dereference of null will be covered by other warning
|
||||
if (ExpressionUtils.isVoidContext(expression) || isDereferenceContext(expression)) return true;
|
||||
// We assume all Void variables as null because you cannot instantiate it without dirty hacks
|
||||
// However reporting them as "always null" looks redundant (dereferences or comparisons will be reported though).
|
||||
if (TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_VOID, expression.getType())) return true;
|
||||
if (isFlagCheck(anchor)) return true;
|
||||
boolean condition = isCondition(expression);
|
||||
if (!condition && expression instanceof PsiReferenceExpression) {
|
||||
|
||||
@@ -29,4 +29,8 @@ class Test {
|
||||
native Object process(@Nullable Object obj);
|
||||
|
||||
native void doSmth(@Nullable Object obj);
|
||||
|
||||
void bar(Void p) {
|
||||
System.out.println(p);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user