mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
method refs: treat boxed types as with anonymous
This commit is contained in:
@@ -815,21 +815,6 @@ public class TypeConversionUtil {
|
||||
}
|
||||
|
||||
public static boolean boxingConversionApplicable(final PsiType left, final PsiType right) {
|
||||
if (right instanceof PsiMethodReferenceType) {
|
||||
final JavaResolveResult result = ((PsiMethodReferenceType)right).getExpression().advancedResolve(false);
|
||||
PsiElement element = result.getElement();
|
||||
final PsiClassType.ClassResolveResult functionalInterfaceResult = PsiUtil.resolveGenericsClassInType(left);
|
||||
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceResult);
|
||||
if (element instanceof PsiMethod && interfaceMethod != null) {
|
||||
final PsiType[] parameterTypes = ((PsiMethod)element).getSignature(result.getSubstitutor()).getParameterTypes();
|
||||
final PsiType[] argTypes = interfaceMethod.getSignature(functionalInterfaceResult.getSubstitutor()).getParameterTypes();
|
||||
if (parameterTypes.length != argTypes.length) return false;
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
if (boxingConversionApplicable(parameterTypes[i], argTypes[i])) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (left instanceof PsiPrimitiveType && !PsiType.NULL.equals(left)) {
|
||||
return right instanceof PsiClassType && isAssignable(left, right);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class MyTest1 {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
call(1, MyTest1::m);
|
||||
call<error descr="Ambiguous method call: both 'MyTest1.call(int, I1)' and 'MyTest1.call(int, I2)' match">(1, MyTest1::m)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class MyTest2 {
|
||||
static void call(Integer i, I s) { }
|
||||
|
||||
static void test() {
|
||||
call<error descr="Ambiguous method call: both 'MyTest2.call(int, I)' and 'MyTest2.call(Integer, I)' match">(1, MyTest2::m)</error>; //ambiguous
|
||||
call(1, MyTest2::m); //call(int i, I s)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user