inference: ensure nested methods lift their bounds (IDEA-122681)

This commit is contained in:
Anna Kozlova
2014-03-24 12:49:41 +01:00
parent 86cf8fe4e7
commit 5bd221386d
3 changed files with 33 additions and 7 deletions

View File

@@ -245,12 +245,12 @@ public class InferenceSession {
return prepareSubstitution();
}
private static void collectAdditionalConstraints(PsiParameter[] parameters,
PsiExpression[] args,
PsiMethod parentMethod,
PsiSubstitutor siteSubstitutor,
Set<ConstraintFormula> additionalConstraints,
boolean varargs) {
private void collectAdditionalConstraints(PsiParameter[] parameters,
PsiExpression[] args,
PsiMethod parentMethod,
PsiSubstitutor siteSubstitutor,
Set<ConstraintFormula> additionalConstraints,
boolean varargs) {
for (int i = 0; i < args.length; i++) {
if (args[i] != null) {
PsiType parameterType = getParameterType(parameters, i, siteSubstitutor, varargs);
@@ -267,7 +267,8 @@ public class InferenceSession {
final JavaResolveResult result = callExpression.resolveMethodGenerics();
if (result instanceof MethodCandidateInfo) {
final PsiMethod method = ((MethodCandidateInfo)result).getElement();
LOG.assertTrue(method != null);
//need to get type parameters for 2 level nested expressions (they won't be covered by expression constraints on this level?!)
initBounds(method.getTypeParameters());
final PsiExpression[] newArgs = argumentList.getExpressions();
final PsiParameter[] newParams = method.getParameterList().getParameters();
if (newParams.length > 0) {

View File

@@ -0,0 +1,21 @@
import java.util.Set;
import java.util.function.Supplier;
class IDEA122681 {
private static <E> Set<E> getSet(E element) {
return null;
}
private static <T> T getObject(Supplier<T> supplier) {
return null;
}
private static Object getObjectFromString(String string) {
return null;
}
private static void callGetSet() {
getSet(getObjectFromString(getObject(String ::new)));
}
}

View File

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