java 7 vs java 6 & primitive varargs (IDEA-70370)

This commit is contained in:
Anna Kozlova
2012-11-04 18:45:43 +01:00
parent 39f730b820
commit 8f68586d5e
3 changed files with 22 additions and 7 deletions
@@ -649,9 +649,10 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return substitutor;
}
public static void checkPrimitiveVarargs(final List<CandidateInfo> conflicts,
final int argumentsCount) {
PsiMethod objectVararg = null;
public void checkPrimitiveVarargs(final List<CandidateInfo> conflicts,
final int argumentsCount) {
if (JavaVersionService.getInstance().isAtLeast(myArgumentsList, JavaSdkVersion.JDK_1_7)) return;
CandidateInfo objectVararg = null;
for (CandidateInfo conflict : conflicts) {
final PsiMethod method = (PsiMethod)conflict.getElement();
final int parametersCount = method.getParameterList().getParametersCount();
@@ -660,21 +661,21 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
final PsiType componentType = ((PsiArrayType)type).getComponentType();
final PsiClassType classType = PsiType.getJavaLangObject(method.getManager(), GlobalSearchScope.allScope(method.getProject()));
if (Comparing.equal(componentType, classType)) {
objectVararg = method;
objectVararg = conflict;
}
}
}
if (objectVararg != null) {
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) {
CandidateInfo conflict = iterator.next();
for (CandidateInfo conflict : conflicts) {
PsiMethod method = (PsiMethod)conflict.getElement();
if (method != objectVararg && method != null && method.isVarArgs()) {
final int paramsCount = method.getParameterList().getParametersCount();
final PsiType type = method.getParameterList().getParameters()[paramsCount - 1].getType();
final PsiType componentType = ((PsiArrayType)type).getComponentType();
if (argumentsCount == paramsCount - 1 && componentType instanceof PsiPrimitiveType) {
iterator.remove();
conflicts.remove(objectVararg);
break;
}
}
}
@@ -0,0 +1,13 @@
class Devk1 {
public void main(String args[]) {
foo();
}
private void <warning descr="Private method 'foo(java.lang.Object...)' is never used">foo</warning>(Object... objects) {
System.out.println("OBJECTS" + objects);
}
private void foo(int... ints) {
System.out.println("INTS" + ints);
}
}
@@ -181,6 +181,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA57311() throws Exception { doTest(false); }
public void testIDEA57309() throws Exception { doTest(false); }
public void testIDEA90802() throws Exception { doTest(false); }
public void testIDEA70370() throws Exception { doTest(true); }
public void testInaccessibleThroughWildcard() throws Exception { doTest17Incompatibility();}
public void testInconvertibleTypes() throws Exception { doTest(false); }
public void testIncompatibleReturnType() throws Exception { doTest(false); }