mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
method reference: don't start containing class parameter type inference for receiver-reference; corresponding substitutor should be already known (IDEA-146604; IDEA-147223)
This commit is contained in:
@@ -1330,8 +1330,6 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
else if (PsiMethodReferenceUtil.isResolvedBySecondSearch(reference, signature, varargs, isStatic, parameters.length)) { //instance methods
|
||||
initBounds(containingClass.getTypeParameters());
|
||||
|
||||
final PsiType pType = signature.getParameterTypes()[0];
|
||||
|
||||
// 15.13.1 If the ReferenceType is a raw type, and there exists a parameterization of this type, T, that is a supertype of P1,
|
||||
@@ -1347,6 +1345,7 @@ public class InferenceSession {
|
||||
return receiverSubstitutor;
|
||||
}
|
||||
}
|
||||
mySiteSubstitutor = mySiteSubstitutor.putAll(receiverSubstitutor);
|
||||
psiSubstitutor = receiverSubstitutor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class C {
|
||||
private static void foo(final Stream<Predicate<Boolean>> stream) {
|
||||
BinaryOperator<Predicate<Boolean>> bo = Predicate::and;
|
||||
Predicate<Boolean> notWorking = stream.reduce(Predicate::and).orElse(t -> true);
|
||||
}
|
||||
|
||||
public static void bar(Stream<E> stream) {
|
||||
Object[] array = stream
|
||||
.sorted(Enum::compareTo)
|
||||
.toArray();
|
||||
System.out.println("array = " + Arrays.toString(array));
|
||||
}
|
||||
enum E {;}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class MyTest<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<E> add(E... elements) {
|
||||
public Builder<E> add(E... <warning descr="Parameter 'elements' is never used">elements</warning>) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,6 +442,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testContainingClassTypeParametersShouldNotBeInferredDuringMethodReferenceProcessing() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user