do not search null-literal argument for notnull var-arg parameter IDEA-160134

This commit is contained in:
Dmitry Batkovich
2016-08-23 13:13:40 +03:00
parent c63435aa86
commit 5de3184fb3
3 changed files with 19 additions and 0 deletions
@@ -42,6 +42,10 @@ public class JavaNullMethodArgumentUtil {
}
public static void searchNullArgument(@NotNull PsiMethod method, final int argumentIdx, @NotNull Processor<PsiExpression> nullArgumentProcessor) {
final PsiParameter parameter = method.getParameterList().getParameters()[argumentIdx];
if (parameter.getType() instanceof PsiEllipsisType) {
return;
}
final GlobalSearchScope scope = findScopeWhereNullArgumentCanPass(method, argumentIdx);
if (scope == null) return;
MethodReferencesSearch.search(method, scope, true).forEach(ref -> {
@@ -0,0 +1,11 @@
import org.jetbrains.annotations.NotNull;
class Test {
static void someMethod(@NotNull Object... varargParameter) {
}
public static void main(String[] args) {
someMethod(null, null);
}
}
@@ -171,6 +171,10 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase
doTest();
}
public void testNullPassedAsPartNotNullAnnotatedOfVarArg() {
doTest();
}
public void testHonorParameterDefaultInSetters() {
DataFlowInspectionTest.addJavaxNullabilityAnnotations(myFixture);
DataFlowInspectionTest.addJavaxDefaultNullabilityAnnotations(myFixture);