new inference: lift type params from referenced method

(cherry picked from commit 057bd4d4d576711b77141b64987079ef8d59a583)
This commit is contained in:
anna
2013-11-25 16:48:01 +01:00
parent 12baf9a2bd
commit a1bf37f805
4 changed files with 24 additions and 1 deletions
@@ -239,7 +239,7 @@ public class InferenceSession {
return mySiteSubstitutor;
}
private void initBounds(PsiTypeParameter... typeParameters) {
public void initBounds(PsiTypeParameter... typeParameters) {
for (PsiTypeParameter parameter : typeParameters) {
if (myInferenceVariables.containsKey(parameter)) continue;
InferenceVariable variable = new InferenceVariable(parameter);
@@ -154,6 +154,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
return false;
}
session.initBounds(method.getTypeParameters());
constraints.add(new TypeCompatibilityConstraint(returnType, referencedMethodReturnType));
}
@@ -0,0 +1,18 @@
import java.util.List;
class Test {
interface Function<K, V> {
V _(K k);
}
static {
foo(Test::asList);
}
public static <T> List<T> asList(T... a) {
return null;
}
public static <C> void foo(Function<String, C> fn) { }
}
@@ -104,6 +104,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testLiftMethodReferenceTypeParams() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}