Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasikanth Bharadwaj2014-06-30 05:58:56 +0000
committerJayaprakash Arthanareeswaran2014-10-30 05:37:36 +0000
commit08076aab664568469f1ee82b59145601a1474680 (patch)
tree01c62bf278fff73cdf5777bc032297b74f7f3726
parent749b59284271247657ca51c33e5663606de91e58 (diff)
downloadeclipse.jdt.core-08076aab664568469f1ee82b59145601a1474680.tar.gz
eclipse.jdt.core-08076aab664568469f1ee82b59145601a1474680.tar.xz
eclipse.jdt.core-08076aab664568469f1ee82b59145601a1474680.zip
Fixed Bug 428845 - eclipse compiler does not flag ambiguous method call
in some cases Signed-off-by: Sasikanth Bharadwaj<saammana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java33
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java2
2 files changed, 34 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
index dac4c2021d..9595fce585 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
@@ -4464,4 +4464,37 @@ public void testBug426521() {
"The method m(List<Object>, Object) is ambiguous for the type Test\n" +
"----------\n");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428845
+public void testBug428845() {
+ runNegativeTest(
+ new String[] {
+ "AmbiguousTest.java",
+ "import java.io.File;\n" +
+ "public class AmbiguousTest {\n" +
+ " static interface IInterface {\n" +
+ " public void method(File file);\n" +
+ " }\n" +
+ " static abstract class AbstractClass implements IInterface {\n" +
+ " public void method(File file) {\n" +
+ " System.err.println(\"file\");\n" +
+ " }\n" +
+ " public void method(String string) {\n" +
+ " System.err.println(\"string\");\n" +
+ " }\n" +
+ " }\n" +
+ " private static AbstractClass newAbstractClass() {\n" +
+ " return new AbstractClass() {};\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " newAbstractClass().method(null);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in AmbiguousTest.java (at line 18)\n" +
+ " newAbstractClass().method(null);\n" +
+ " ^^^^^^\n" +
+ "The method method(File) is ambiguous for the type AmbiguousTest.AbstractClass\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index 501c8ab740..29a28b44f7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -1276,7 +1276,7 @@ public abstract class Scope {
continue; // can skip this method since concreteMatch overrides it
}
}
- if (sourceLevel18) {
+ if (sourceLevel18 || !(compatibleMethod.isVarargs() && compatibleMethod instanceof ParameterizedGenericMethodBinding)) {
for (int j = 0; j < startFoundSize; j++) {
MethodBinding classMethod = (MethodBinding) found.elementAt(j);
if (classMethod != null && methodVerifier.areMethodsCompatible(classMethod, compatibleMethod))

Back to the top