mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[java-psi] IDEA-379921 Guava. False positive NPE when return value from an unknown list
GitOrigin-RevId: 2a5ef25b56c60058db25210028e3e802cfbf0dc2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9c4314a68e
commit
0afc6f7842
@@ -118,15 +118,15 @@ public final class DfaPsiUtil {
|
||||
if (DumbService.isDumb(owner.getProject())) return Nullability.UNKNOWN;
|
||||
NullabilityAnnotationInfo fromAnnotation = getNullabilityFromAnnotation(owner, ignoreParameterNullabilityInference);
|
||||
if (fromAnnotation != null) {
|
||||
if (fromAnnotation.getNullability() != Nullability.NOT_NULL) {
|
||||
if (resultType != null && fromAnnotation.getNullability() != Nullability.NOT_NULL) {
|
||||
PsiType type = PsiUtil.getTypeByPsiElement(owner);
|
||||
if (type != null) {
|
||||
PsiAnnotationOwner annotationOwner = fromAnnotation.getAnnotation().getOwner();
|
||||
if (PsiUtil.resolveClassInClassTypeOnly(type) instanceof PsiTypeParameter &&
|
||||
annotationOwner instanceof PsiType && annotationOwner != type) {
|
||||
if (PsiUtil.resolveClassInClassTypeOnly(type) instanceof PsiTypeParameter tp &&
|
||||
annotationOwner instanceof PsiType && annotationOwner != type &&
|
||||
!tp.equals(PsiUtil.resolveClassInClassTypeOnly(resultType))) {
|
||||
// Nullable/Unknown from type hierarchy: should check the instantiation, as it could be more concrete
|
||||
Nullability fromType = getNullabilityFromType(resultType, owner);
|
||||
if (fromType != null) return fromType;
|
||||
return resultType.getNullability().nullability();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ class MyTest {
|
||||
|
||||
}
|
||||
|
||||
void get2(List<String> l1) {
|
||||
System.out.println(Iterables.get(l1, 0).length());
|
||||
}
|
||||
|
||||
void foo(List<String> l1, List<String> l2) {
|
||||
for (String s : Iterables.concat(l1, l2)) {
|
||||
System.out.println(s.length());
|
||||
|
||||
Reference in New Issue
Block a user