mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] Avoid false-positive NPE warnings inside java.lang.System source
Fixes IDEA-316248 Inspection "Method invocation ‘println’ will produce ‘NullPointerException’" on System.err GitOrigin-RevId: 0d257c09bff9712299bc749288703d057dfa3fdb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
622ea3b218
commit
da62a731ac
+1
-1
@@ -120,7 +120,7 @@ public final class JavaDfaValueFactory {
|
||||
private static DfaValue createReferenceValue(DfaValueFactory factory, @NotNull PsiReferenceExpression refExpr) {
|
||||
PsiElement target = refExpr.resolve();
|
||||
if (target instanceof PsiVariable variable) {
|
||||
if (!PsiUtil.isAccessedForWriting(refExpr)) {
|
||||
if (!PsiUtil.isAccessedForWriting(refExpr) && !PlainDescriptor.hasInitializationHacks(variable)) {
|
||||
DfaValue constValue = getConstantFromVariable(factory, variable);
|
||||
if (constValue != null && !maybeUninitializedConstant(constValue, refExpr, variable)) return constValue;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// IDEA-316248
|
||||
package java.lang;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
class System {
|
||||
public static final PrintStream out = null;
|
||||
|
||||
void test() {
|
||||
out.println(1);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -724,4 +724,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testTryWithResourcesCloseThrows() { doTest(); }
|
||||
public void testBooleanOrEquals() { doTest(); }
|
||||
public void testDuplicatedByPointlessBooleanInspection() { doTest(); }
|
||||
public void testSystemOutNullSource() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user