From e386cea3ab20cc5181f6799ebf13a50811e55b23 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 9 Apr 2012 12:12:56 +0200 Subject: [PATCH] ambiguous method calls: conflict resolver, tests (IDEA-78027) --- .../JavaMethodsConflictResolver.java | 3 ++- .../pck/AmbiguousMethodCall.java | 17 +++++++++++++++++ .../daemon/AdvHighlightingJdk7Test.java | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA78027/pck/AmbiguousMethodCall.java 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 f16dd7aaa2ab..55de2515a987 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 @@ -337,7 +337,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ boolean noBoxing = boxingHappening || type1 instanceof PsiPrimitiveType == type2 instanceof PsiPrimitiveType; final boolean allowUncheckedConversion = !method1.hasModifierProperty(PsiModifier.STATIC) && !method2.hasModifierProperty(PsiModifier.STATIC) || - method1.getContainingClass() == method2.getContainingClass(); + InheritanceUtil.isInheritorOrSelf(method1.getContainingClass(), method2.getContainingClass(), true) || + InheritanceUtil.isInheritorOrSelf( method2.getContainingClass(), method1.getContainingClass(),true); final boolean assignable2From1 = noBoxing && TypeConversionUtil.isAssignable(type2, type1, allowUncheckedConversion); final boolean assignable1From2 = noBoxing && TypeConversionUtil.isAssignable(type1, type2, allowUncheckedConversion); if (assignable1From2 || assignable2From1) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA78027/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA78027/pck/AmbiguousMethodCall.java new file mode 100644 index 000000000000..00016a20e6f4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA78027/pck/AmbiguousMethodCall.java @@ -0,0 +1,17 @@ +package pck; +class Test { + void test() { + B.method(new ArgumentB()); + } +} + +class A { + static void method(ArgumentA a) { } +} + +class B extends A { + static void method(ArgumentB b) { } +} + +class ArgumentA {} +class ArgumentB extends ArgumentA {} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java index dadf02462054..7e469bdf81e5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java @@ -164,4 +164,8 @@ public class AdvHighlightingJdk7Test extends DaemonAnalyzerTestCase { public void testAmbiguousIDEA67837() throws Exception { doTestAmbiguous(); } + + public void testAmbiguousIDEA78027() throws Exception { + doTestAmbiguous(); + } }