method ref: ensure capture conversion on first arg of second search

This commit is contained in:
Anna Kozlova
2018-05-22 14:29:48 +03:00
parent 283d328b15
commit c9d3d04e73
3 changed files with 16 additions and 1 deletions

View File

@@ -1627,7 +1627,8 @@ public class InferenceSession {
final PsiType qType = JavaPsiFacade.getElementFactory(method.getProject()).createType(containingClass, psiSubstitutor);
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(qType), pType));
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(qType),
PsiUtil.captureToplevelWildcards(pType, reference)));
if (methodContainingClass != null) {
psiSubstitutor = JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), psiSubstitutor);

View File

@@ -0,0 +1,13 @@
class MyTest {
{
Appender data = Map::appendData;
}
}
interface Map<B> {
void appendData(String appender) ;
}
interface Appender {
void append(Map<?> map, String appender);
}

View File

@@ -184,6 +184,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testPreferErrorOnTopLevelToFailedSubstitutorOnNestedLevel() { doTest(); }
public void testDontIgnoreIncompatibilitiesDuringFirstApplicabilityCheck() { doTest(); }
public void testCaptureOnDedicatedParameterOfSecondSearch() { doTest(); }
private void doTest() {
doTest(false);