mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] Avoid marking annotation method results as non-null
While annotation implementations created by reflection never return nulls, it's possible to create a custom annotation interface implementation and nothing stops from returning null in this case. This leads to false-positives. Fixes IDEA-269686 Wrong inspection message for nullable return value of annotation Rollback IDEA-151174 Annotation method return values are non-nullable GitOrigin-RevId: 88301bd8f5fb69e1e78efc23ecc1416c7c441473
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1136ebed29
commit
d70063b9f2
@@ -84,7 +84,7 @@ public final class DfaPsiUtil {
|
||||
return Nullability.UNKNOWN;
|
||||
}
|
||||
|
||||
if (owner instanceof PsiEnumConstant || PsiUtil.isAnnotationMethod(owner)) {
|
||||
if (owner instanceof PsiEnumConstant) {
|
||||
return Nullability.NOT_NULL;
|
||||
}
|
||||
if (owner instanceof PsiMethod && isEnumPredefinedMethod((PsiMethod)owner)) {
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// "Simplify 'my.value() == null' to false" "true"
|
||||
class Test {
|
||||
void some(SuppressWarnings my) {
|
||||
if (my == null) {
|
||||
System.out.println("null");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Simplify 'my.value() == null' to false" "true"
|
||||
// "Simplify 'my.value() == null' to false" "false"
|
||||
class Test {
|
||||
void some(SuppressWarnings my) {
|
||||
if (my == null || my.value() =<caret>= null) {
|
||||
|
||||
@@ -4,7 +4,7 @@ class Test {
|
||||
}
|
||||
|
||||
static void baz(FooBar annotation) {
|
||||
if (<warning descr="Condition 'annotation.x() == null' is always 'false'">annotation.x() == null</warning>) {
|
||||
if (annotation.x() == null) {
|
||||
System.out.println("null");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user