diff options
| author | Jayaprakash Arthanareeswaran | 2012-11-09 09:38:38 +0000 |
|---|---|---|
| committer | Stephan Herrmann | 2012-11-15 17:02:58 +0000 |
| commit | bf3327534492f80b8d79e6948262e6cef5664121 (patch) | |
| tree | 4d54886bec005d5a5dde45a7d700df4a571ea902 | |
| parent | 90cdf8e8c0e2fd8fdbe1d92522367a844c42ef50 (diff) | |
| download | eclipse.jdt.core-bf3327534492f80b8d79e6948262e6cef5664121.tar.gz eclipse.jdt.core-bf3327534492f80b8d79e6948262e6cef5664121.tar.xz eclipse.jdt.core-bf3327534492f80b8d79e6948262e6cef5664121.zip | |
Fix for bug 393781 - In case of non matching argument list the message
is not informative if short class name matches
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 7b83a1d00b..9162aa6921 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 615b78dea0..27755f8c06 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[] { |
