IDEA-177499 ClassCastException in data flow inspection

This commit is contained in:
Tagir Valeev
2017-08-14 10:27:10 +07:00
parent d308509cb7
commit 4232f8dd41
2 changed files with 10 additions and 1 deletions
@@ -136,7 +136,7 @@ public class DfaExpressionFactory {
}
if (DfaValueFactory.isEffectivelyUnqualified(refExpr) || isStaticFinalConstantWithoutInitializationHacks(var)) {
if (isFieldDereferenceBeforeInitialization(refExpr)) {
if (isFieldDereferenceBeforeInitialization(refExpr) && !(refExpr.getType() instanceof PsiPrimitiveType)) {
return myFactory.getConstFactory().getNull();
}
@@ -4,4 +4,13 @@ class IgnoreNullabilityOnPrimitiveCast {
private static int map(@Nullable int[] mapping, int idx) {
return <warning descr="Array access 'mapping[idx]' may produce 'java.lang.NullPointerException'">mapping[idx]</warning>;
}
static final int TEST;
static {
TEST = 4;
}
final int[] arr = {TEST};
final int val = TEST;
}