mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-57595 'Null is returned from method not declared as @Nullable' inspection should not be reported for Void methods
This commit is contained in:
@@ -29,10 +29,7 @@ import com.intellij.codeInspection.dataFlow.instructions.InstanceofInstruction;
|
||||
import com.intellij.codeInspection.dataFlow.instructions.Instruction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiReturnStatement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.*;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -68,7 +65,9 @@ public class StandardDataFlowRunner extends AnnotationsAwareDataFlowRunner {
|
||||
myIsInMethod = psiBlock.getParent() instanceof PsiMethod;
|
||||
if (myIsInMethod) {
|
||||
PsiMethod method = (PsiMethod)psiBlock.getParent();
|
||||
myInNullableMethod = NullableNotNullManager.isNullable(method);
|
||||
PsiType returnType = method.getReturnType();
|
||||
myInNullableMethod = NullableNotNullManager.isNullable(method) ||
|
||||
returnType != null && returnType.equalsToText(CommonClassNames.JAVA_LANG_VOID);
|
||||
myInNotNullMethod = NullableNotNullManager.isNotNull(method);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ public interface CommonClassNames {
|
||||
@NonNls String JAVA_LANG_CLASS = "java.lang.Class";
|
||||
@NonNls String JAVA_LANG_OVERRIDE = "java.lang.Override";
|
||||
@NonNls String JAVA_LANG_ENUM = "java.lang.Enum";
|
||||
@NonNls String JAVA_LANG_VOID = "java.lang.Void";
|
||||
|
||||
@NonNls String JAVA_LANG_THROWABLE = "java.lang.Throwable";
|
||||
@NonNls String JAVA_LANG_EXCEPTION = "java.lang.Exception";
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
public class BrokenAlignment {
|
||||
|
||||
Void test() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -86,5 +86,6 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
|
||||
public void testAssigningUnknownToNullable() throws Throwable { doTest(); }
|
||||
|
||||
public void testSynchronizingOnNullable() throws Throwable { doTest(); }
|
||||
public void testReturningNullFromVoidMethod() throws Throwable { doTest(); }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user