mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
method references: avoid double substitution (IDEA-126062)
This commit is contained in:
@@ -68,12 +68,11 @@ public class PsiMethodReferenceUtil {
|
||||
|
||||
public static boolean isCorrectAssignment(PsiType[] signatureParameterTypes2,
|
||||
PsiType[] parameterTypes,
|
||||
PsiSubstitutor substitutor,
|
||||
boolean varargs,
|
||||
int offset) {
|
||||
final int min = Math.min(signatureParameterTypes2.length, parameterTypes.length - offset);
|
||||
for (int i = 0; i < min; i++) {
|
||||
final PsiType type1 = substitutor.substitute(parameterTypes[i + offset]);
|
||||
final PsiType type1 = parameterTypes[i + offset];
|
||||
final PsiType type2 = signatureParameterTypes2[i];
|
||||
if (varargs && i == signatureParameterTypes2.length - 1) {
|
||||
if (!TypeConversionUtil.isAssignable(type2, type1) && !TypeConversionUtil.isAssignable(((PsiArrayType)type2).getComponentType(), type1)) {
|
||||
|
||||
@@ -248,13 +248,13 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
|
||||
if (varargs && (!psiMethod.isVarArgs() || myFunctionalMethodVarArgs)) continue;
|
||||
|
||||
if ((varargs || parameterTypes.length == signatureParameterTypes2.length) &&
|
||||
PsiMethodReferenceUtil.isCorrectAssignment(signatureParameterTypes2, parameterTypes, substitutor, varargs, 0)) {
|
||||
PsiMethodReferenceUtil.isCorrectAssignment(signatureParameterTypes2, parameterTypes, varargs, 0)) {
|
||||
firstCandidates.add(conflict);
|
||||
}
|
||||
|
||||
if (hasReceiver &&
|
||||
(varargs || parameterTypes.length == signatureParameterTypes2.length + 1) &&
|
||||
PsiMethodReferenceUtil.isCorrectAssignment(signatureParameterTypes2, parameterTypes, substitutor, varargs, 1)) {
|
||||
PsiMethodReferenceUtil.isCorrectAssignment(signatureParameterTypes2, parameterTypes, varargs, 1)) {
|
||||
secondCandidates.add(conflict);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.util.function.Consumer;
|
||||
class Pipeline<I, O> implements Consumer<I> {
|
||||
@Override public final void accept(I input) {}
|
||||
|
||||
public <K> void then(Pipeline<O, K> pipeline, final Observable<O> observable) {
|
||||
observable.subscribe(pipeline::accept);
|
||||
}
|
||||
}
|
||||
|
||||
interface Observable<T> {
|
||||
void subscribe(Consumer<T> x);
|
||||
}
|
||||
@@ -257,6 +257,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA126062() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user