mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-analysis] Eclipse annotations: TYPE_BOUND/TYPE_ARGUMENT targets should not apply to mixed places like FIELD+TYPE_USE
Fixes IDEA-272286 org.eclipse.jdt.annotation.NonNullByDefault should not add @NonNull to Local variables GitOrigin-RevId: a9c8f21ea5e50ef4696d2c98e5a0b01e40dd1797
This commit is contained in:
committed by
intellij-monorepo-bot
parent
105488ed63
commit
61bf6f49a8
+2
-1
@@ -45,7 +45,8 @@ class EclipseAnnotationSupport implements AnnotationPackageSupport {
|
||||
else if (value instanceof PsiLiteralExpression && Boolean.FALSE.equals(((PsiLiteralExpression)value).getValue())) {
|
||||
targets = ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
boolean targetApplies = StreamEx.of(targets).map(TARGET_MAP::get).nonNull().anyMatch(loc -> ArrayUtil.contains(loc, types));
|
||||
boolean targetApplies = StreamEx.of(targets).map(TARGET_MAP::get).nonNull()
|
||||
.anyMatch(loc -> loc == PsiAnnotation.TargetType.TYPE_USE ? types.length == 1 && types[0] == loc : ArrayUtil.contains(loc, types));
|
||||
return new NullabilityAnnotationInfo(anno, targetApplies ? Nullability.NOT_NULL : Nullability.UNKNOWN, true);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -16,6 +16,10 @@ public class EclipseDefaultTypeUse {
|
||||
// List::add is not annotated but ArrayList<String> is defined in context of TYPE_USE NonNullByDefault annotation
|
||||
a.add(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
|
||||
}
|
||||
|
||||
void local() {
|
||||
String s = null;
|
||||
}
|
||||
}
|
||||
@NonNullByDefault
|
||||
@FunctionalInterface
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.lang.annotation.*;
|
||||
@NonNullByDefault
|
||||
class X {
|
||||
void test() {
|
||||
String x = Y.getFoo();
|
||||
@NonNull String x = Y.getFoo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user