mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
overload resolution with varargs: don't prefer promitive varargs when no arg is provided (IDEA-140759)
This commit is contained in:
@@ -444,12 +444,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
}
|
||||
|
||||
private static boolean isBoxingHappened(PsiType argType, PsiType parameterType, @NotNull LanguageLevel languageLevel) {
|
||||
if (argType == null) return parameterType instanceof PsiPrimitiveType;
|
||||
if (parameterType instanceof PsiClassType) {
|
||||
parameterType = ((PsiClassType)parameterType).setLanguageLevel(languageLevel);
|
||||
}
|
||||
|
||||
return TypeConversionUtil.boxingConversionApplicable(parameterType, argType);
|
||||
return argType != null && TypeConversionUtil.boxingConversionApplicable(parameterType, argType);
|
||||
}
|
||||
|
||||
private Specifics isMoreSpecific(@NotNull MethodCandidateInfo info1,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
class Test {
|
||||
public void test(String... <warning descr="Parameter 'a' is never used">a</warning>){}
|
||||
|
||||
public void test(int... <warning descr="Parameter 'a' is never used">a</warning>){}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Test().test<error descr="Ambiguous method call: both 'Test.test(String...)' and 'Test.test(int...)' match">()</error>;
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPrimitiveVarargsAreNoMoreSpecificThanNonPrimitiveWhenNoArgIsActuallyProvided() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user