method refs: varargs methods should be checked for parameter numbers (IDEA-133173)

This commit is contained in:
Anna Kozlova
2014-11-19 16:27:21 +01:00
parent b7db7163a7
commit fa29801a8a
3 changed files with 19 additions and 1 deletions

View File

@@ -94,7 +94,7 @@ public class PsiMethodReferenceUtil {
return false;
}
}
return true;
return !varargs || parameterTypes.length - 1 <= argTypes.length - offset;
}
@NotNull

View File

@@ -0,0 +1,14 @@
import java.util.stream.Stream;
class A {
private void test5(Integer i, String... strings) {}
private void <warning descr="Private method 'test5(java.lang.Integer, java.lang.Integer, java.lang.String...)' is never used">test5</warning>(Integer i, Integer b, String... strings) {
System.out.println(i);
System.out.println(b);
System.out.println(strings);
}
void p(Stream<Integer> stream){
stream.forEach(this::test5);
}
}

View File

@@ -330,6 +330,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testVarargsParametersCountComparison() throws Exception {
doTest(true);
}
private void doTest() {
doTest(false);
}