mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
new inference: lift type params from referenced method
(cherry picked from commit 057bd4d4d576711b77141b64987079ef8d59a583)
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
+1
@@ -154,6 +154,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
return false;
|
||||
}
|
||||
|
||||
session.initBounds(method.getTypeParameters());
|
||||
constraints.add(new TypeCompatibilityConstraint(returnType, referencedMethodReturnType));
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -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) { }
|
||||
}
|
||||
+4
@@ -104,6 +104,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLiftMethodReferenceTypeParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user