new inference: reject varargs as method reference target

(cherry picked from commit 77017d7790b78c5bb20c591e2588c1eccd0f96d7)
This commit is contained in:
Anna Kozlova
2014-03-10 14:18:03 +01:00
parent 0f40eb9bed
commit fb20169d40
3 changed files with 25 additions and 1 deletions

View File

@@ -706,7 +706,7 @@ public class TypeConversionUtil {
final PsiType lType = ((PsiMethodReferenceType)left).getExpression().getFunctionalInterfaceType();
return Comparing.equal(rType, lType);
}
return methodReferenceExpression.isAcceptable(left);
return !(left instanceof PsiArrayType) && methodReferenceExpression.isAcceptable(left);
}
if (right instanceof PsiLambdaExpressionType) {
final PsiLambdaExpression rLambdaExpression = ((PsiLambdaExpressionType)right).getExpression();

View File

@@ -0,0 +1,20 @@
class Test {
interface IntMapper {
int map();
}
interface LongMapper {
long map();
}
void m(IntMapper im1, IntMapper... im) { }
void m(LongMapper... lm) { }
{
m<error descr="Ambiguous method call: both 'Test.m(IntMapper, IntMapper...)' and 'Test.m(LongMapper...)' match">(this ::ii)</error>;
}
int ii() {return 0;}
}

View File

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