mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
dfa: just don't assume initialized final fields are notnull, it doesn't help, but hurts and slows things down (IDEA-124323)
This commit is contained in:
-19
@@ -115,19 +115,6 @@ public class DfaValueFactory {
|
||||
return getConstFactory().create(literal);
|
||||
}
|
||||
|
||||
private static boolean isNotNullExpression(PsiExpression initializer, PsiType type) {
|
||||
if (initializer instanceof PsiNewExpression) {
|
||||
return true;
|
||||
}
|
||||
if (initializer instanceof PsiPolyadicExpression) {
|
||||
if (type != null && type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DfaValue createReferenceValue(PsiReferenceExpression referenceExpression) {
|
||||
PsiElement psiSource = referenceExpression.resolve();
|
||||
@@ -139,12 +126,6 @@ public class DfaValueFactory {
|
||||
if (variable.hasModifierProperty(PsiModifier.FINAL) && !variable.hasModifierProperty(PsiModifier.TRANSIENT)) {
|
||||
DfaValue constValue = getConstFactory().create(variable);
|
||||
if (constValue != null) return constValue;
|
||||
|
||||
PsiExpression initializer = variable.getInitializer();
|
||||
PsiType type = initializer == null ? null : initializer.getType();
|
||||
if (initializer != null && type != null && isNotNullExpression(initializer, type)) {
|
||||
return createTypeValue(type, Nullness.NOT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!variable.hasModifierProperty(PsiModifier.VOLATILE) && isEffectivelyUnqualified(referenceExpression)) {
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class Test {
|
||||
public static final Test INSTANCE = new Test();
|
||||
|
||||
public Test() {
|
||||
if (INSTANCE == null) {
|
||||
System.out.println("Instance is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, world!");
|
||||
}
|
||||
}
|
||||
@@ -192,6 +192,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testLastConstantConditionInAnd() { doTest(); }
|
||||
|
||||
public void testTransientFinalField() { doTest(); }
|
||||
public void testFinalFieldDuringInitialization() { doTest(); }
|
||||
public void _testSymmetricUncheckedCast() { doTest(); } // http://youtrack.jetbrains.com/issue/IDEABKL-6871
|
||||
public void testNullCheckDoesntAffectUncheckedCast() { doTest(); }
|
||||
public void testThrowNull() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user