IDEA-228079 Bad code green when dereferencing an unannotated parameter with nullable super

GitOrigin-RevId: ff3b4f3c7c01c2fb5aa90107037517653cadafa2
This commit is contained in:
Peter Gromov
2020-01-08 18:49:07 +01:00
committed by intellij-monorepo-bot
parent 680f4703db
commit 3a7ab57eb2
4 changed files with 19 additions and 3 deletions

View File

@@ -128,10 +128,13 @@ public class DfaPsiUtil {
private static Nullability getNullabilityFromAnnotation(PsiModifierListOwner owner, boolean ignoreParameterNullabilityInference) {
NullableNotNullManager manager = NullableNotNullManager.getInstance(owner.getProject());
NullabilityAnnotationInfo info = manager.findEffectiveNullabilityInfo(owner);
if (info == null ||
ignoreParameterNullabilityInference && owner instanceof PsiParameter && AnnotationUtil.isInferredAnnotation(info.getAnnotation())) {
if (info == null) {
return Nullability.UNKNOWN;
}
if (ignoreParameterNullabilityInference && owner instanceof PsiParameter && AnnotationUtil.isInferredAnnotation(info.getAnnotation())) {
List<PsiParameter> supers = AnnotationUtil.getSuperAnnotationOwners((PsiParameter)owner);
return ContainerUtil.exists(supers, each -> manager.isNullable(each, false)) ? Nullability.NULLABLE : Nullability.UNKNOWN;
}
return info.getNullability();
}

View File

@@ -64,7 +64,7 @@ public interface VariableDescriptor {
}
PsiType type = getType(null);
LongRangeSet range = LongRangeSet.fromPsiElement(getPsiElement());
DfType dfType = DfTypes.typedObject(type, DfaPsiUtil.getElementNullability(type, getPsiElement()));
DfType dfType = DfTypes.typedObject(type, DfaPsiUtil.getElementNullabilityIgnoringParameterInference(type, getPsiElement()));
if (dfType instanceof DfIntegralType) {
dfType = ((DfIntegralType)dfType).meetRange(range);
}