new inference: lift containing class type parameters for method references

(cherry picked from commit a341be1196484b6e4c33a7d10059d2bec5bdf955)
This commit is contained in:
anna
2013-11-24 17:24:05 +01:00
parent 912722b922
commit e493e0c778
3 changed files with 25 additions and 3 deletions

View File

@@ -154,9 +154,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
}
session.initBounds(method.getTypeParameters());
if (myExpression.isConstructor()) {
session.initBounds(containingClass.getTypeParameters());
}
session.initBounds(containingClass.getTypeParameters());
constraints.add(new TypeCompatibilityConstraint(returnType, referencedMethodReturnType));
}

View File

@@ -0,0 +1,20 @@
import java.util.List;
class Test {
interface Function<X, Y> {
Y m(X x);
}
interface Node<E> {
List<E> foo();
}
class Data<T, I> {
Data(I state, Function<I, List<T>> fun) { }
}
<O> Data<O, Node<O>> test(Node<O> collection) {
return new Data<>(collection, Node::foo);
}
}

View File

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