mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java 7 vs java 6 & primitive varargs (IDEA-70370)
This commit is contained in:
+8
-7
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -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); }
|
||||
|
||||
Reference in New Issue
Block a user