mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
new inference: capture implicit param types (IDEA-132716)
This commit is contained in:
@@ -95,13 +95,13 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
|||||||
}
|
}
|
||||||
for (int i = 1; i < targetParameters.length; i++) {
|
for (int i = 1; i < targetParameters.length; i++) {
|
||||||
constraints.add(new TypeCompatibilityConstraint(session.substituteWithInferenceVariables(psiSubstitutor.substitute(parameters[i - 1].getType())),
|
constraints.add(new TypeCompatibilityConstraint(session.substituteWithInferenceVariables(psiSubstitutor.substitute(parameters[i - 1].getType())),
|
||||||
signature.getParameterTypes()[i]));
|
PsiUtil.captureToplevelWildcards(signature.getParameterTypes()[i], myExpression)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (targetParameters.length == parameters.length) {
|
else if (targetParameters.length == parameters.length) {
|
||||||
for (int i = 0; i < targetParameters.length; i++) {
|
for (int i = 0; i < targetParameters.length; i++) {
|
||||||
constraints.add(new TypeCompatibilityConstraint(session.substituteWithInferenceVariables(psiSubstitutor.substitute(parameters[i].getType())),
|
constraints.add(new TypeCompatibilityConstraint(session.substituteWithInferenceVariables(psiSubstitutor.substitute(parameters[i].getType())),
|
||||||
signature.getParameterTypes()[i]));
|
PsiUtil.captureToplevelWildcards(signature.getParameterTypes()[i], myExpression)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
interface A<T> {
|
||||||
|
}
|
||||||
|
|
||||||
|
interface B<BT> {
|
||||||
|
void method(BT arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
public static void test() {
|
||||||
|
method1(Test::<error descr="Cannot resolve method 'method2'">method2</error>);
|
||||||
|
}
|
||||||
|
|
||||||
|
static <M> void method1(B<A<? super M>> arg) { }
|
||||||
|
|
||||||
|
static void method2(A<? super String> arg) { }
|
||||||
|
}
|
||||||
@@ -470,6 +470,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCapturedTypesOfImplicitParameterTypes() throws Exception {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
private void doTest() {
|
private void doTest() {
|
||||||
doTest(false);
|
doTest(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user