diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java index da8846fa1eb2..808ab129a807 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java @@ -490,7 +490,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ if (MethodSignatureUtil.isSubsignature(method1.getSignature(info1.getSubstitutor()), method2.getSignature(info2.getSubstitutor()))) { isMoreSpecific = Specifics.SECOND; } - else if (method1.hasModifierProperty(PsiModifier.STATIC) && method2.hasModifierProperty(PsiModifier.STATIC)) { + else if (method1.hasModifierProperty(PsiModifier.STATIC) && method2.hasModifierProperty(PsiModifier.STATIC) && boxingHappened[0] == 0) { isMoreSpecific = Specifics.SECOND; } } @@ -498,7 +498,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ if (MethodSignatureUtil.isSubsignature(method2.getSignature(info2.getSubstitutor()), method1.getSignature(info1.getSubstitutor()))) { isMoreSpecific = Specifics.FIRST; } - else if (method1.hasModifierProperty(PsiModifier.STATIC) && method2.hasModifierProperty(PsiModifier.STATIC)) { + else if (method1.hasModifierProperty(PsiModifier.STATIC) && method2.hasModifierProperty(PsiModifier.STATIC) && boxingHappened[0] == 0) { isMoreSpecific = Specifics.FIRST; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/ambiguousCalls/BoxingAndStaticMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/ambiguousCalls/BoxingAndStaticMethods.java new file mode 100644 index 000000000000..487bcd218186 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/ambiguousCalls/BoxingAndStaticMethods.java @@ -0,0 +1,47 @@ +import java.util.Collections; +import java.util.Iterator; + +public class AmbiguousTest extends AbstractTest { + public void testFoo() { + Iterator list = Collections.singleton(1).iterator(); + assertEquals(1, list.next()); + } +} + +abstract class AbstractTest extends Assert { + public static void assertEquals(float expected, float actual) { + Assert.assertEquals(expected, actual, 0.00001); + } +} +class Assert { + protected Assert() { /* compiled code */ } + public static void assertEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual) { /* compiled code */ } + public static void assertEquals(java.lang.Object expected, java.lang.Object actual) { /* compiled code */ } + public static void assertEquals(java.lang.String message, double expected, double actual, double delta) { /* compiled code */ } + public static void assertEquals(long expected, long actual) { /* compiled code */ } + public static void assertEquals(java.lang.String message, long expected, long actual) { /* compiled code */ } + /** + * @deprecated + */ + @java.lang.Deprecated + public static void assertEquals(double expected, double actual) { /* compiled code */ } + + /** + * @deprecated + */ + @java.lang.Deprecated + public static void assertEquals(java.lang.String message, double expected, double actual) { /* compiled code */ } + + public static void assertEquals(double expected, double actual, double delta) { /* compiled code */ } + /** + * @deprecated + */ + @java.lang.Deprecated + public static void assertEquals(java.lang.String message, java.lang.Object[] expecteds, java.lang.Object[] actuals) { /* compiled code */ } + + /** + * @deprecated + */ + @java.lang.Deprecated + public static void assertEquals(java.lang.Object[] expecteds, java.lang.Object[] actuals) { /* compiled code */ } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java new file mode 100644 index 000000000000..77cfbeee15dd --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.compiler.JavacQuirksInspection; +import com.intellij.codeInspection.redundantCast.RedundantCastInspection; +import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; +import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NonNls; + +/** + * This class is for "lightweight" tests only, i.e. those which can run inside default light project set up + * For "heavyweight" tests use AdvHighlightingTest + */ +public class AmbiguousMethodCallTest extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/ambiguousCalls"; + + private void doTest(boolean checkWarnings, boolean checkInfos, InspectionProfileEntry... tools) throws Exception { + for (InspectionProfileEntry tool : tools) { enableInspectionTool(tool); } + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); + } + + private void doTest(boolean checkWarnings, boolean checkWeakWarnings, boolean checkInfos, InspectionProfileEntry... tools) throws Exception { + for (InspectionProfileEntry tool : tools) { enableInspectionTool(tool); } + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); + } + + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{ + new UnusedSymbolLocalInspection(), + new UncheckedWarningLocalInspection(), + new JavacQuirksInspection(), + new RedundantCastInspection() + }; + } + + public void testBoxingAndStaticMethods() throws Exception { + doTest(false, false); + } +}