mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
same parameter value inspection should not warn if method is used in method reference expression (IDEA-207552)
This commit is contained in:
@@ -401,6 +401,7 @@ public class RefJavaUtilImpl extends RefJavaUtil {
|
||||
!PsiType.VOID
|
||||
.equals(LambdaUtil.getFunctionalInterfaceReturnType(getFunctionalInterfaceType((UCallableReferenceExpression)refExpression)))) {
|
||||
refMethod.setReturnValueUsed(true);
|
||||
refMethod.setParametersAreUnknown();
|
||||
addTypeReference(uFrom, returnType, refFrom.getRefManager());
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -152,6 +152,15 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod {
|
||||
}
|
||||
}
|
||||
|
||||
public void setParametersAreUnknown() {
|
||||
for (RefParameter parameter : myParameters) {
|
||||
((RefParameterImpl)parameter).clearTemplateValue();
|
||||
}
|
||||
for (RefMethod method : getSuperMethods()) {
|
||||
((RefMethodImpl)method).setParametersAreUnknown();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAppMain(PsiMethod psiMethod, RefMethod refMethod) {
|
||||
if (!refMethod.isStatic()) return false;
|
||||
if (!PsiType.VOID.equals(psiMethod.getReturnType())) return false;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems/>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
public class Test {
|
||||
|
||||
|
||||
public void foo() {
|
||||
bar(null);
|
||||
|
||||
List<String> strings = Collections.singletonList("NotNull!");
|
||||
strings.forEach(this::bar);
|
||||
}
|
||||
|
||||
private void bar(@Nullable String goo) {
|
||||
System.out.println(goo);
|
||||
}
|
||||
}
|
||||
+4
@@ -94,4 +94,8 @@ public class SameParameterValueLocalTest extends InspectionTestCase {
|
||||
public void testOverrideGroovy() {
|
||||
doTest(getGlobalTestDir(), myTool);
|
||||
}
|
||||
|
||||
public void testMethodReferences() {
|
||||
doTest(getGlobalTestDir(), myTool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,4 +105,8 @@ public class SameParameterValueTest extends InspectionTestCase {
|
||||
public void testOverrideGroovy() {
|
||||
doTest(getTestDir(), myTool, false, true);
|
||||
}
|
||||
|
||||
public void testMethodReferences() {
|
||||
doTest(getTestDir(), myTool, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user