mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] Do not allow null in ephemeral value
GitOrigin-RevId: cca32e434c96998346fc6759f3d699bc6ada799a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cf5e59d8f3
commit
f65c12ccbd
+5
-3
@@ -249,9 +249,11 @@ class DfGenericObjectType extends DfAntiConstantType<Object> implements DfRefere
|
||||
} else if (!myNotValues.containsAll(otherNotValues)) {
|
||||
notValues = new THashSet<>(myNotValues);
|
||||
notValues.addAll(otherNotValues);
|
||||
DfEphemeralReferenceType ephemeralValue = checkEphemeral(constraint, notValues);
|
||||
if (ephemeralValue != null) {
|
||||
return ephemeralValue;
|
||||
if (nullability == DfaNullability.NOT_NULL) {
|
||||
DfEphemeralReferenceType ephemeralValue = checkEphemeral(constraint, notValues);
|
||||
if (ephemeralValue != null) {
|
||||
return ephemeralValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,24 @@ class Test {
|
||||
else if (x == MyEnum.C) {
|
||||
s = "C";
|
||||
}
|
||||
System.out.println(s.trim());
|
||||
System.out.println(s.<warning descr="Method invocation 'trim' may produce 'NullPointerException'">trim</warning>()); // reachable if x is null
|
||||
}
|
||||
|
||||
void test2(MyEnum x) {
|
||||
void test1(@NotNull MyEnum x) {
|
||||
String s = null;
|
||||
if (x == MyEnum.A) {
|
||||
s = "A";
|
||||
}
|
||||
else if (x == MyEnum.B) {
|
||||
s = "B";
|
||||
}
|
||||
else if (x == MyEnum.C) {
|
||||
s = "C";
|
||||
}
|
||||
System.out.println(s.trim()); // ephemerably reachable
|
||||
}
|
||||
|
||||
void test2(@NotNull MyEnum x) {
|
||||
String s = null;
|
||||
if (x == MyEnum.A) {
|
||||
s = "A";
|
||||
|
||||
Reference in New Issue
Block a user