mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
new inference: skip lambda return expression additional constraints during overload resolution
This commit is contained in:
@@ -299,6 +299,13 @@ public class InferenceSession {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
final PsiExpression arg = PsiUtil.skipParenthesizedExprDown(args[i]);
|
||||
if (arg != null) {
|
||||
if (MethodCandidateInfo.isOverloadCheck() && arg instanceof PsiLambdaExpression) {
|
||||
for (Object expr : MethodCandidateInfo.ourOverloadGuard.currentStack()) {
|
||||
if (PsiTreeUtil.getParentOfType((PsiElement)expr, PsiLambdaExpression.class) == arg) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final InferenceSession nestedCallSession = findNestedCallSession(arg);
|
||||
final PsiType parameterType =
|
||||
nestedCallSession.substituteWithInferenceVariables(getParameterType(parameters, i, siteSubstitutor, varargs));
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
class MyTest {
|
||||
interface I<T, E> {
|
||||
List<E> m(Set<T> s);
|
||||
}
|
||||
|
||||
<K, L>List<K> foo(I<K, L> i){return null;}
|
||||
|
||||
<K, H> List<K> bar(Runnable l) {return null;}
|
||||
List<String> bar(Function<String, String> s) {return null;}
|
||||
|
||||
String baz(Set<Integer> b, String x) {return null;}
|
||||
List<Integer> baz(Iterator<Integer> s, Iterator<Integer> i) {return null;}
|
||||
|
||||
{
|
||||
List<Integer> l = foo(a -> bar(b -> b<ref>az(a, b)));
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,10 @@ public class TypeInference18Test extends ResolveTestCase {
|
||||
doTestMethodCall();
|
||||
}
|
||||
|
||||
public void testLambdaChainConflictResolution() throws Exception {
|
||||
doTestMethodCall();
|
||||
}
|
||||
|
||||
public void testCachedSubstitutionDuringOverloadResolution() throws Exception {
|
||||
PsiReference ref = configureByFile("/codeInsight/daemonCodeAnalyzer/lambda/resolve/" + getTestName(false) + ".java");
|
||||
assertNotNull(ref);
|
||||
|
||||
Reference in New Issue
Block a user