mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-18 12:31:26 +07:00
[java-inspections] NullableStuffInspectionBase: do not report "non-annotated overrides annotated" in the presense of container annotation
Fixes IDEA-323362 IntelliJ gives "Not annotated method overrides method annotated with @Nonnull" despite @NonNullApi GitOrigin-RevId: 1b4298ffc3a1fc9ce4f4e5b9412e3af5a3b116d9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f46f96d05f
commit
5f3ce51f8a
@@ -127,7 +127,7 @@ public abstract class NullableNotNullManager {
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
return findNullityDefaultInHierarchy(owner);
|
||||
return findContainerAnnotation(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +166,7 @@ public abstract class NullableNotNullManager {
|
||||
NullabilityAnnotationInfo plain = findPlainAnnotation(parameter, false, false, getAllNullabilityAnnotationsWithNickNames());
|
||||
// Plain not null annotation is not inherited
|
||||
if (plain != null) return null;
|
||||
NullabilityAnnotationInfo defaultInfo = findNullityDefaultInHierarchy(parameter);
|
||||
NullabilityAnnotationInfo defaultInfo = findContainerAnnotation(parameter);
|
||||
if (defaultInfo != null) {
|
||||
return defaultInfo.getNullability() == Nullability.NOT_NULL ? defaultInfo.withInheritedFrom(parameter) : null;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public abstract class NullableNotNullManager {
|
||||
}
|
||||
|
||||
private @Nullable NullabilityAnnotationInfo findNullityDefaultFiltered(@NotNull PsiModifierListOwner owner) {
|
||||
NullabilityAnnotationInfo defaultInfo = findNullityDefaultInHierarchy(owner);
|
||||
NullabilityAnnotationInfo defaultInfo = findContainerAnnotation(owner);
|
||||
if (defaultInfo != null && (defaultInfo.getNullability() == Nullability.NULLABLE || !hasHardcodedContracts(owner))) {
|
||||
return defaultInfo;
|
||||
}
|
||||
@@ -294,7 +294,15 @@ public abstract class NullableNotNullManager {
|
||||
return findNullabilityDefault(context, PsiAnnotation.TargetType.TYPE_USE);
|
||||
}
|
||||
|
||||
@Nullable NullabilityAnnotationInfo findNullityDefaultInHierarchy(@NotNull PsiModifierListOwner owner) {
|
||||
/**
|
||||
* Looks for applicable container annotation, ignoring explicit, inferred, external, or inherited annotations.
|
||||
* Usually, should not be used directly, as {@link #findEffectiveNullabilityInfo(PsiModifierListOwner)} will
|
||||
* return container annotation if it's applicable.
|
||||
*
|
||||
* @param owner member to find annotation for
|
||||
* @return container annotation applicable to the owner location
|
||||
*/
|
||||
public @Nullable NullabilityAnnotationInfo findContainerAnnotation(@NotNull PsiModifierListOwner owner) {
|
||||
return findNullabilityDefault(owner, AnnotationTargetUtil.getTargetsForLocation(owner.getModifierList()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user