mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
method refs: non-raw receiver type should influence collected constraints (IDEA-140002)
This commit is contained in:
+5
-1
@@ -1308,6 +1308,10 @@ public class InferenceSession {
|
||||
psiSubstitutor = receiverSubstitutor;
|
||||
}
|
||||
}
|
||||
else if (methodContainingClass != null) {
|
||||
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, psiSubstitutor);
|
||||
LOG.assertTrue(psiSubstitutor != null, "derived: " + containingClass + "; super: " + methodContainingClass);
|
||||
}
|
||||
|
||||
final PsiType qType = JavaPsiFacade.getElementFactory(method.getProject()).createType(containingClass, psiSubstitutor);
|
||||
|
||||
@@ -1315,7 +1319,7 @@ public class InferenceSession {
|
||||
|
||||
for (int i = 0; i < signature.getParameterTypes().length - 1; i++) {
|
||||
final PsiType interfaceParamType = signature.getParameterTypes()[i + 1];
|
||||
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, PsiSubstitutor.EMPTY, varargs)),
|
||||
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, psiSubstitutor, varargs)),
|
||||
PsiImplUtil.normalizeWildcardTypeByPosition(interfaceParamType, reference)));
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -88,7 +88,6 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
final PsiType qualifierType = PsiMethodReferenceUtil.getQualifierType(myExpression);
|
||||
final PsiClass qualifierClass = PsiUtil.resolveClassInType(qualifierType);
|
||||
if (qualifierClass != null) {
|
||||
session.initBounds(myExpression, qualifierClass.getTypeParameters());
|
||||
final PsiType pType = signature.getParameterTypes()[0];
|
||||
constraints.add(new StrictSubtypingConstraint(session.substituteWithInferenceVariables(qualifierType), pType));
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import java.util.*;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collector;
|
||||
|
||||
class Test {
|
||||
public static <T5> Collector<T5, Set<T5>, Set<T5>> foo(Supplier<Set<T5>> setConstructor,
|
||||
BinaryOperator<Set<T5>> rBinaryOperator) {
|
||||
|
||||
return Collector.of(setConstructor, Set<T5>:: add, rBinaryOperator);
|
||||
}
|
||||
|
||||
public static <T> Collector<T, Set<T>, Set<T>> foo() {
|
||||
final Supplier<Set<T>> setConstructor = HashSet::new;
|
||||
|
||||
return Collector.of(
|
||||
setConstructor,
|
||||
Set<T>::add,
|
||||
(Set<T> s1, Set<T> s2) -> {
|
||||
s1.addAll(s2);
|
||||
return s1;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+4
@@ -398,6 +398,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConstraintsFromNonRawReceiverType() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user