summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJayaprakash Arthanareeswaran2012-11-09 04:38:38 (EST)
committer Stephan Herrmann2012-11-15 12:02:58 (EST)
commitbf3327534492f80b8d79e6948262e6cef5664121 (patch)
tree4d54886bec005d5a5dde45a7d700df4a571ea902
parent90cdf8e8c0e2fd8fdbe1d92522367a844c42ef50 (diff)
downloadeclipse.jdt.core-bf3327534492f80b8d79e6948262e6cef5664121.zip
eclipse.jdt.core-bf3327534492f80b8d79e6948262e6cef5664121.tar.gz
eclipse.jdt.core-bf3327534492f80b8d79e6948262e6cef5664121.tar.bz2
Fix for bug 393781 - In case of non matching argument list the message
is not informative if short class name matches
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java50
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java4
2 files changed, 54 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java
index 7b83a1d..9162aa6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java
@@ -8095,4 +8095,54 @@ public void test379530() {
null
);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=393781
+public void test393781() {
+ Map compilerOptions = getCompilerOptions(); // OPTION_ReportRawTypeReference
+ Object oldOption = compilerOptions.get(CompilerOptions.OPTION_ReportRawTypeReference);
+ compilerOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ try {
+ this.runNegativeTest(
+ new String[] {
+ "p/X.java",
+ "public class X {\n" +
+ " public void foo(Map map, String str) {}\n" +
+ " public void foo1() {}\n" +
+ " public void bar(java.util.Map map) {\n" +
+ " foo(map, \"\");\n" +
+ " foo(map);\n" +
+ " foo();\n" +
+ " foo1(map, \"\");\n" +
+ " }\n" +
+ "}\n" +
+ "class Map {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in p\\X.java (at line 5)\n" +
+ " foo(map, \"\");\n" +
+ " ^^^\n" +
+ "The method foo(Map, java.lang.String) in the type X is not applicable for the arguments (java.util.Map, java.lang.String)\n" +
+ "----------\n" +
+ "2. ERROR in p\\X.java (at line 6)\n" +
+ " foo(map);\n" +
+ " ^^^\n" +
+ "The method foo(Map, String) in the type X is not applicable for the arguments (Map)\n" +
+ "----------\n" +
+ "3. ERROR in p\\X.java (at line 7)\n" +
+ " foo();\n" +
+ " ^^^\n" +
+ "The method foo(Map, String) in the type X is not applicable for the arguments ()\n" +
+ "----------\n" +
+ "4. ERROR in p\\X.java (at line 8)\n" +
+ " foo1(map, \"\");\n" +
+ " ^^^^\n" +
+ "The method foo1() in the type X is not applicable for the arguments (Map, String)\n" +
+ "----------\n",
+ null,
+ true,
+ compilerOptions /* default options */
+ );
+ } finally {
+ compilerOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, oldOption);
+ }
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 615b78d..27755f8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -3793,6 +3793,10 @@ public void invalidMethod(MessageSend messageSend, MethodBinding method) {
String parameterTypeNames = typesAsString(problemMethod.parameters, false);
String closestParameterTypeShortNames = typesAsString(shownMethod, true);
String parameterTypeShortNames = typesAsString(problemMethod.parameters, true);
+ if (closestParameterTypeShortNames.equals(parameterTypeShortNames)) {
+ closestParameterTypeShortNames = closestParameterTypeNames;
+ parameterTypeShortNames = parameterTypeNames;
+ }
this.handle(
IProblem.ParameterMismatch,
new String[] {