mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
varargs (IDEA-92641)
This commit is contained in:
@@ -671,10 +671,17 @@ public class LambdaUtil {
|
||||
|
||||
final int min = Math.min(signatureParameterTypes2.length, signatureParameterTypes1.length);
|
||||
for (int i = 0; i < min; i++) {
|
||||
final PsiType type1 = signatureParameterTypes1[offset + i];
|
||||
final PsiType type2 = isVarargs && i == min - 1 ? ((PsiArrayType)signatureParameterTypes2[i]).getComponentType() : signatureParameterTypes2[i];
|
||||
if (!TypeConversionUtil.isAssignable(type2, psiSubstitutor.substitute(GenericsUtil.eliminateWildcards(type1)))) {
|
||||
return false;
|
||||
final PsiType type1 = psiSubstitutor.substitute(GenericsUtil.eliminateWildcards(signatureParameterTypes1[offset + i]));
|
||||
if (isVarargs && i == min - 1) {
|
||||
if (!TypeConversionUtil.isAssignable(((PsiArrayType)signatureParameterTypes2[i]).getComponentType(), type1) &&
|
||||
!TypeConversionUtil.isAssignable(signatureParameterTypes2[i], type1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!TypeConversionUtil.isAssignable(signatureParameterTypes2[i], psiSubstitutor.substitute(GenericsUtil.eliminateWildcards(type1)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -428,11 +428,14 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
(!myBeginsWithReferenceType || staticOrValidConstructorRef || (psiMethod.isConstructor() && conflict.isStaticsScopeCorrect()))) {
|
||||
boolean correct = true;
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
final PsiType type1 = parameterTypes[i];
|
||||
final PsiType type2 = varArgs && i >= signatureParameterTypes2.length - 1 ?
|
||||
((PsiArrayType)signatureParameterTypes2[signatureParameterTypes2.length -1]).getComponentType() :
|
||||
signatureParameterTypes2[i];
|
||||
correct &= TypeConversionUtil.isAssignable(type2, subst.substitute(GenericsUtil.eliminateWildcards(type1)));
|
||||
final PsiType type1 = subst.substitute(GenericsUtil.eliminateWildcards(parameterTypes[i]));
|
||||
if (varArgs && i >= signatureParameterTypes2.length - 1) {
|
||||
final PsiType type2 = signatureParameterTypes2[signatureParameterTypes2.length - 1];
|
||||
correct &= TypeConversionUtil.isAssignable(type2, type1) || TypeConversionUtil.isAssignable(((PsiArrayType)type2).getComponentType(), type1);
|
||||
}
|
||||
else {
|
||||
correct &= TypeConversionUtil.isAssignable(signatureParameterTypes2[i], type1);
|
||||
}
|
||||
}
|
||||
if (correct) {
|
||||
firstCandidates.add(conflict);
|
||||
|
||||
@@ -7,4 +7,16 @@ class Test {
|
||||
|
||||
interface Foo {
|
||||
void bar();
|
||||
}
|
||||
|
||||
class Test1 {
|
||||
public static void main(String... args) {}
|
||||
|
||||
void test() {
|
||||
Foo1 foo = Test1::main;
|
||||
}
|
||||
}
|
||||
|
||||
interface Foo1 {
|
||||
void bar(String... s);
|
||||
}
|
||||
Reference in New Issue
Block a user