mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: propagate current substitutors during additional constrains processing (IDEA-118965)
This commit is contained in:
@@ -468,12 +468,12 @@ public class LambdaUtil {
|
||||
final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters);
|
||||
if (finalLambdaIdx < parameters.length) {
|
||||
if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]);
|
||||
if (cachedType != null && paramIdx > -1) {
|
||||
if (cachedType != null) {
|
||||
final PsiMethod interfaceMethod = getFunctionalInterfaceMethod(cachedType);
|
||||
if (interfaceMethod != null) {
|
||||
final PsiClassType.ClassResolveResult cachedResult = PsiUtil.resolveGenericsClassInType(cachedType);
|
||||
final PsiType interfaceMethodParameterType = interfaceMethod.getParameterList().getParameters()[paramIdx].getType();
|
||||
if (!dependsOnTypeParams(cachedResult.getSubstitutor().substitute(interfaceMethodParameterType), cachedType, expression)){
|
||||
if (!dependsOnTypeParams(paramIdx == -1 ? cachedType :
|
||||
cachedResult.getSubstitutor().substitute(interfaceMethod.getParameterList().getParameters()[paramIdx].getType()), cachedType, expression)){
|
||||
return cachedType;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -696,7 +696,13 @@ public class InferenceSession {
|
||||
|
||||
additionalConstraints.removeAll(subset);
|
||||
|
||||
PsiSubstitutor substitutor = resolveBounds(varsToResolve, mySiteSubstitutor, false);
|
||||
PsiSubstitutor substitutor = resolveBounds(varsToResolve, mySiteSubstitutor, true);
|
||||
|
||||
if (myContext instanceof PsiCallExpression) {
|
||||
PsiExpressionList argumentList = ((PsiCallExpression)myContext).getArgumentList();
|
||||
LOG.assertTrue(argumentList != null);
|
||||
MethodCandidateInfo.updateSubstitutor(argumentList, substitutor);
|
||||
}
|
||||
|
||||
for (ConstraintFormula additionalConstraint : subset) {
|
||||
additionalConstraint.apply(substitutor);
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import java.util.Map;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Bug
|
||||
{
|
||||
|
||||
void foo(Stream<Bug> words){
|
||||
words.collect(toMap(w -> 1, (a, b) -> a + b));
|
||||
}
|
||||
|
||||
public static <T, K, U>
|
||||
Collector<T, ?, Map<K,U>> toMap(Function<Bug, U> valueMapper,
|
||||
BinaryOperator<U> mergeFunction) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testAmbiguityReturnValueResolution3() { doTest(); }
|
||||
public void testLambdaOnVarargsPlace1() { doTest(); }
|
||||
public void testInferenceFromSecondLambda() { doTest(); }
|
||||
public void _testAcceptRawSubstForLambda() { doTest(); }
|
||||
public void testAcceptRawSubstForLambda() { doTest(); }
|
||||
public void testCheckFunctionalInterfaceAccess() { doTest(); }
|
||||
public void testVoidCompatibility() { doTest(); }
|
||||
public void testConditionalInferenceFromOppositePart() { doTest(); }
|
||||
|
||||
+4
@@ -107,6 +107,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAdditionalConstraintSubstitution() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user