mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
new inference: reject methrefs with inconsistent number of parameters
(cherry picked from commit 9c41270192e140ed28067e2740333c6d3fa49bd2)
This commit is contained in:
@@ -98,10 +98,12 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
for (int i = 1; i < targetParameters.length; i++) {
|
||||
constraints.add(new TypeCompatibilityConstraint(psiSubstitutor.substitute(parameters[i - 1].getType()), GenericsUtil.eliminateWildcards(substitutor.substitute(targetParameters[i].getType()))));
|
||||
}
|
||||
} else {
|
||||
} else if (targetParameters.length == parameters.length) {
|
||||
for (int i = 0; i < targetParameters.length; i++) {
|
||||
constraints.add(new TypeCompatibilityConstraint(psiSubstitutor.substitute(parameters[i].getType()), GenericsUtil.eliminateWildcards(substitutor.substitute(targetParameters[i].getType()))));
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (returnType != PsiType.VOID) {
|
||||
if (applicableMethodReturnType == PsiType.VOID) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test {
|
||||
interface I {
|
||||
void m(Integer x1, Integer x2, Integer x3);
|
||||
}
|
||||
|
||||
static class Foo {
|
||||
static void foo() {}
|
||||
}
|
||||
|
||||
<T> void bar(I i) {}
|
||||
|
||||
void test() {
|
||||
bar<error descr="'bar(Test.I)' in 'Test' cannot be applied to '(<method reference>)'">(Foo::foo)</error>;
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testAssertNumberOfParameters() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user