void (@NotNull PsiLiteralExpression value) { super.visitLiteralExpression(value); final String text = value.getText(); if (!PsiKeyword.NULL.equals(text)) { return; } final PsiElement parent = ExpressionUtils.getPassThroughParent(value); if (!(parent instanceof PsiReturnStatement) && !(parent instanceof PsiLambdaExpression)) { return; } final PsiElement element = PsiTreeUtil.getParentOfType(value, PsiMethod.class, PsiLambdaExpression.class); final PsiMethod method; final PsiType returnType; final boolean lambda; if (element instanceof PsiMethod) { method = (PsiMethod)element; returnType = method.getReturnType(); lambda = false; } else if (element instanceof PsiLambdaExpression) { final PsiType functionalInterfaceType = ((PsiLambdaExpression)element).getFunctionalInterfaceType(); method = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType); returnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType); lambda = true; } else { return; } if (method == null || returnType == null) { return; } if (TypeUtils.isOptional(returnType)) { registerError(value, value); return; } if (lambda) { if (m_ignorePrivateMethods || isInNullableContext(element)) { return; } } else { if (m_ignorePrivateMethods && method.hasModifierProperty(PsiModifier.PRIVATE)) { return; } final PsiClass containingClass = method.getContainingClass(); if (containingClass instanceof PsiAnonymousClass) { if (m_ignorePrivateMethods || isInNullableContext(containingClass.getParent())) { return; } } } final Project project = method.getProject(); final NullabilityAnnotationInfo info = NullableNotNullManager.getInstance(project).findEffectiveNullabilityInfo(method); if (info != null && info.getNullability() == Nullability.NULLABLE && !info.isInferred()) { return; } if (DfaPsiUtil.getTypeNullability(returnType) == Nullability.NULLABLE) { return; } if (CollectionUtils.isCollectionClassOrInterface(returnType)) { if (m_reportCollectionMethods) { registerError(value, value); } } else if (returnType.getArrayDimensions() > 0) { if (m_reportArrayMethods) { registerError(value, value); } } else if (!returnType.equalsToText("java.lang.Void")){ if (m_reportObjectMethods) { registerError(value, value); } } }