### Eclipse Workspace Patch 1.0 #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.59 diff -u -r1.59 StaticImportTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 28 Jan 2008 21:53:50 -0000 1.59 +++ src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 13 Mar 2008 18:58:22 -0000 @@ -2099,5 +2099,27 @@ " ^^^^\n" + "The method getZ() is undefined for the type X\n" + "----------\n"); - } + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216930 + public void test058() { + this.runConformTest( + new String[] { + "p/X.java", + "package p;\n" + + "import static p.A.a;\n" + + "public class X {\n" + + " void foo(W w) { a(w).a(w); }\n" + + "}\n", + "p/A.java", + "package p;\n" + + "public class A {\n" + + " public static A a(W... w) { return null; }\n" + + " public A a(W w) { return null; }\n" + + "}\n", + "p/W.java", + "package p;\n" + + "public class W {}\n" + }, + ""); + } } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.324 diff -u -r1.324 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 22 Feb 2008 09:49:37 -0000 1.324 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 13 Mar 2008 18:58:23 -0000 @@ -1045,6 +1045,11 @@ // Internal use only - use findMethod() public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) { + return findMethod(receiverType, selector, argumentTypes, invocationSite, false); + } + + // Internal use only - use findMethod() + public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, boolean inStaticContext) { ReferenceBinding currentType = receiverType; boolean receiverTypeIsInterface = receiverType.isInterface(); ObjectVector found = new ObjectVector(3); @@ -1257,6 +1262,18 @@ } } + if (inStaticContext) { + MethodBinding[] staticCandidates = new MethodBinding[visiblesCount]; + int staticCount = 0; + for (int i = 0; i < visiblesCount; i++) + if (candidates[i].isStatic()) + staticCandidates[staticCount++] = candidates[i]; + if (staticCount == 1) + return staticCandidates[0]; + if (staticCount > 1) + return mostSpecificMethodBinding(staticCandidates, staticCount, argumentTypes, invocationSite, receiverType); + } + MethodBinding mostSpecificMethod = mostSpecificMethodBinding(candidates, visiblesCount, argumentTypes, invocationSite, receiverType); if (searchForDefaultAbstractMethod) { // search interfaces for a better match if (mostSpecificMethod.isValidBinding()) @@ -1909,13 +1926,13 @@ if (importBinding.onDemand) { if (!skipOnDemand && resolvedImport instanceof ReferenceBinding) // answers closest approximation, may not check argumentTypes or visibility - possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite); + possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite, true); } else { if (resolvedImport instanceof MethodBinding) { MethodBinding staticMethod = (MethodBinding) resolvedImport; if (CharOperation.equals(staticMethod.selector, selector)) // answers closest approximation, may not check argumentTypes or visibility - possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite); + possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite, true); } else if (resolvedImport instanceof FieldBinding) { // check to see if there are also methods with the same name FieldBinding staticField = (FieldBinding) resolvedImport; @@ -1925,7 +1942,7 @@ TypeBinding referencedType = getType(importName, importName.length - 1); if (referencedType != null) // answers closest approximation, may not check argumentTypes or visibility - possible = findMethod((ReferenceBinding) referencedType, selector, argumentTypes, invocationSite); + possible = findMethod((ReferenceBinding) referencedType, selector, argumentTypes, invocationSite, true); } } }