### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java,v retrieving revision 1.114 diff -u -r1.114 CompilationUnitScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 19 Mar 2008 14:57:25 -0000 1.114 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 19 Mar 2008 17:18:20 -0000 @@ -358,8 +358,12 @@ } else { Binding importBinding = findSingleImport(compoundName, importReference.isStatic()); if (!importBinding.isValidBinding()) { - problemReporter().importProblem(importReference, importBinding); - continue nextImport; + if (importBinding instanceof ProblemFieldBinding && importBinding.problemId() == ProblemReasons.Ambiguous) { + // keep it as is unless a duplicate can be found below + } else { + problemReporter().importProblem(importReference, importBinding); + continue nextImport; + } } if (importBinding instanceof PackageBinding) { problemReporter().cannotImportPackage(importReference); @@ -518,12 +522,10 @@ ReferenceBinding type = (ReferenceBinding) binding; FieldBinding field = findField(type, name, null, true); if (field != null) { - if (field.problemId() == ProblemReasons.Ambiguous) { - field = ((ProblemFieldBinding)field).closestMatch; - } - if (field.isStatic() && field.canBeSeenBy(type, null, this)) { + if (field.problemId() == ProblemReasons.Ambiguous && ((ProblemFieldBinding) field).closestMatch.isStatic()) + return field; // keep the ambiguous field instead of a possible method match + if (field.isValidBinding() && field.isStatic() && field.canBeSeenBy(type, null, this)) return field; - } } // look to see if there is a static method with the same selector @@ -705,6 +707,8 @@ if (importBinding.resolvedImport == null) { importBinding.resolvedImport = findSingleImport(importBinding.compoundName, importBinding.isStatic()); if (!importBinding.resolvedImport.isValidBinding() || importBinding.resolvedImport instanceof PackageBinding) { + if (importBinding.resolvedImport instanceof ProblemFieldBinding && importBinding.resolvedImport.problemId() == ProblemReasons.Ambiguous) + return importBinding.resolvedImport; if (this.imports != null) { ImportBinding[] newImports = new ImportBinding[imports.length - 1]; for (int i = 0, n = 0, max = this.imports.length; i < max; i++) #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java,v retrieving revision 1.62 diff -u -r1.62 StaticImportTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 19 Mar 2008 05:01:31 -0000 1.62 +++ src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 19 Mar 2008 17:18:21 -0000 @@ -2214,6 +2214,50 @@ " ^^^^^\n" + "The import q.A.a cannot be resolved\n" + "----------\n"); - } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=183211 - variation + public void test063() { + this.runNegativeTest( + new String[] { + "p/X.java", + "package p;\n" + + "import static q.A.a;\n" + + "import static q.A.b;\n" + + "public class X {\n" + + " void test() {\n" + + " System.out.println(a);\n" + + " System.out.println(b);\n" + + " System.out.println(b(1));\n" + + " }\n" + + "}\n", + "q/A.java", + "package q;\n" + + "interface I {\n" + + " String a = \"1\";\n" + + " String b = \"2\";\n" + + "}\n" + + "interface J {\n" + + " String a = \"3\";\n" + + "}\n" + + "class B {\n" + + " public static String a = \"4\";\n" + + " public static String b = \"5\";\n" + + " public static String b(int i) { return \"6\"; }\n" + + "}\n" + + "public class A extends B implements J, I {}\n", + }, + "----------\n" + + "1. ERROR in p\\X.java (at line 6)\n" + + " System.out.println(a);\n" + + " ^\n" + + "The field a is ambiguous\n" + + "----------\n" + + "2. ERROR in p\\X.java (at line 7)\n" + + " System.out.println(b);\n" + + " ^\n" + + "The field b is ambiguous\n" + + "----------\n" + ); + } }