method refs: missed super substitutor (IDEA-136717)

This commit is contained in:
Anna Kozlova
2015-02-19 20:28:38 +01:00
parent f6e4a45adf
commit ab09470050
3 changed files with 28 additions and 2 deletions

View File

@@ -1189,6 +1189,7 @@ public class InferenceSession {
final boolean varargs = candidateInfo.isVarargs();
final PsiMethod method = candidateInfo.getElement();
final PsiClass methodContainingClass = method.getContainingClass();
final PsiMethodReferenceUtil.QualifierResolveResult qualifierResolveResult = PsiMethodReferenceUtil.getQualifierResolveResult(reference);
@@ -1199,10 +1200,10 @@ public class InferenceSession {
final PsiParameter[] parameters = method.getParameterList().getParameters();
final boolean isStatic = method.hasModifierProperty(PsiModifier.STATIC);
PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor();
if (parameters.length == functionalMethodParameters.length && !varargs || isStatic && varargs) {//static methods
PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor();
if (method.isConstructor() && PsiUtil.isRawSubstitutor(containingClass, psiSubstitutor)) {
//15.13.1 If ClassType is a raw type, but is not a non-static member type of a raw type,
//the candidate notional member methods are those specified in §15.9.3 for a
@@ -1211,6 +1212,11 @@ public class InferenceSession {
psiSubstitutor = PsiSubstitutor.EMPTY;
}
if (methodContainingClass != null) {
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, psiSubstitutor);
LOG.assertTrue(psiSubstitutor != null);
}
for (int i = 0; i < functionalMethodParameters.length; i++) {
final PsiType pType = signature.getParameterTypes()[i];
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, psiSubstitutor, varargs)),
@@ -1223,7 +1229,6 @@ public class InferenceSession {
final PsiType pType = signature.getParameterTypes()[0];
PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor();
// 15.13.1 If the ReferenceType is a raw type, and there exists a parameterization of this type, T, that is a supertype of P1,
// the type to search is the result of capture conversion (5.1.10) applied to T;
// otherwise, the type to search is the same as the type of the first search. Again, the type arguments, if any, are given by the method reference.

View File

@@ -0,0 +1,17 @@
import java.util.Set;
class Test {
private static class Form<E, L extends Logic<E>> {
public void process(L logic, Set<FieldModel<E, ?>> fieldModels) {
fieldModels.forEach(logic::declareField);
}
}
private static class FieldModel<E, T> {
}
private static class Logic<E> {
public <T> void declareField(FieldModel<E, T> field) {
}
}
}

View File

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