mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 22:11:40 +07:00
method references: site substitution for method references without receiver (IDEA-134261)
This commit is contained in:
@@ -1101,7 +1101,7 @@ public class InferenceSession {
|
||||
|
||||
for (int i = 0; i < functionalMethodParameters.length; i++) {
|
||||
final PsiType pType = signature.getParameterTypes()[i];
|
||||
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, PsiSubstitutor.EMPTY, varargs)),
|
||||
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, qualifierResolveResult.getSubstitutor(), varargs)),
|
||||
PsiImplUtil.normalizeWildcardTypeByPosition(pType, reference)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,6 @@ class MyTest1 {
|
||||
static void foo(I3 i) {}
|
||||
|
||||
static {
|
||||
foo<error descr="Ambiguous method call: both 'MyTest1.foo(I1)' and 'MyTest1.foo(I2)' match">(Foo::new)</error>;
|
||||
foo<error descr="Cannot resolve method 'foo(<method reference>)'">(Foo::new)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ class Test {
|
||||
static void meth4(I3 s) { }
|
||||
|
||||
static {
|
||||
meth1(<error descr="Inferred type 'java.lang.String' for type parameter 'X' is not within its bound; should extend 'java.lang.Number'">Foo::new</error>);
|
||||
meth1(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
|
||||
meth2(Foo::new);
|
||||
meth3(<error descr="Inferred type 'java.lang.Object' for type parameter 'X' is not within its bound; should extend 'java.lang.Number'">Foo::new</error>);
|
||||
meth4<error descr="Ambiguous method call: both 'Test.meth4(I1)' and 'Test.meth4(I2)' match">(Foo::new)</error>;
|
||||
meth3(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
|
||||
meth4<error descr="Cannot resolve method 'meth4(<method reference>)'">(Foo::new)</error>;
|
||||
|
||||
meth1(<error descr="Inferred type 'java.lang.String' for type parameter 'X' is not within its bound; should extend 'java.lang.Number'">Test::foo</error>);
|
||||
meth2(Test::foo);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
|
||||
public void foo(final Logic<String> logic, Set<Map<String, String>> models) {
|
||||
final Consumer<Map<String, String>> action = logic::declareField;
|
||||
}
|
||||
|
||||
private static class Logic<E> {
|
||||
public <T> void declareField(Map<E, T> field) {}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -338,6 +338,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testSiteSubstitutionOfNonReceiverReference() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user