skip warnings for constructor refs with varargs (IDEA-174074)

This commit is contained in:
Anna Kozlova
2017-06-27 19:41:35 +03:00
parent 857b2bf810
commit 088510d098
3 changed files with 16 additions and 1 deletions

View File

@@ -245,7 +245,8 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
final PsiResolveHelper helper = JavaPsiFacade.getInstance(methodReferenceExpression.getProject()).getResolveHelper();
final PsiType[] paramTypes =
member instanceof PsiMethod ? ((PsiMethod)member).getSignature(PsiSubstitutor.EMPTY).getParameterTypes() : PsiType.EMPTY_ARRAY;
LOG.assertTrue(paramTypes.length == signature.getParameterTypes().length, "expr: " + methodReferenceExpression + "; " +
LOG.assertTrue(paramTypes.length == signature.getParameterTypes().length ||
member instanceof PsiMethod && ((PsiMethod)member).isVarArgs(), "expr: " + methodReferenceExpression + "; " +
paramTypes.length + "; " +
Arrays.toString(signature.getParameterTypes()));
if (Arrays.deepEquals(signature.getParameterTypes(), paramTypes)) {

View File

@@ -0,0 +1,13 @@
import java.util.function.Function;
class Foo<H> {
private Foo(Foo s, Foo... ss) {}
{
foo(Foo::new);
}
private <T> void foo(final Function<Foo, T> param) { }
}

View File

@@ -171,6 +171,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testNonExactMethodReferenceOnRawClassType() { doTest(); }
public void testIncludeOnlyTypeParametersUsedInParameterTypesExcludeThoseUsedInReturnOnly() { doTest(); }
public void testMethodREfToContainingMethodWithGenericParam() { doTest(); }
public void testRawClassTypeOnConstructorWithVarargs() { doTest(); }
public void testDistinguishCapturedWildcardsByDifferentParameters() throws Exception { doTest(); }
public void testConstructorRefOnClassWithRecursiveTypeParameter() throws Exception { doTest(); }
public void testWildcardInCheckedCompatibilityConstraints() { doTest(); }