View | Details | Raw Unified | Return to bug 216930
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java (-1 / +23 lines)
Lines 2099-2103 Link Here
2099
				"	                   ^^^^\n" + 
2099
				"	                   ^^^^\n" + 
2100
				"The method getZ() is undefined for the type X<T>\n" + 
2100
				"The method getZ() is undefined for the type X<T>\n" + 
2101
				"----------\n");		
2101
				"----------\n");		
2102
		}		
2102
		}
2103
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=216930
2104
	public void test058() {
2105
		this.runConformTest(
2106
			new String[] {
2107
				"p/X.java",
2108
				"package p;\n" + 
2109
				"import static p.A.a;\n" + 
2110
				"public class X {\n" + 
2111
				"   void foo(W w) { a(w).a(w); }\n" + 
2112
				"}\n",
2113
				"p/A.java",
2114
				"package p;\n" + 
2115
				"public class A {\n" + 
2116
				"   public static A a(W... w) { return null; }\n" + 
2117
				"   public A a(W w) { return null; }\n" + 
2118
				"}\n",
2119
				"p/W.java",
2120
				"package p;\n" + 
2121
				"public class W {}\n"
2122
			},
2123
			"");		
2124
		}
2103
}
2125
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-3 / +20 lines)
Lines 1045-1050 Link Here
1045
1045
1046
	// Internal use only - use findMethod()
1046
	// Internal use only - use findMethod()
1047
	public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1047
	public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1048
		return findMethod(receiverType, selector, argumentTypes, invocationSite, false);
1049
	}
1050
1051
	// Internal use only - use findMethod()
1052
	public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, boolean inStaticContext) {
1048
		ReferenceBinding currentType = receiverType;
1053
		ReferenceBinding currentType = receiverType;
1049
		boolean receiverTypeIsInterface = receiverType.isInterface();
1054
		boolean receiverTypeIsInterface = receiverType.isInterface();
1050
		ObjectVector found = new ObjectVector(3);
1055
		ObjectVector found = new ObjectVector(3);
Lines 1257-1262 Link Here
1257
			}
1262
			}
1258
		}
1263
		}
1259
1264
1265
		if (inStaticContext) {
1266
			MethodBinding[] staticCandidates = new MethodBinding[visiblesCount];
1267
			int staticCount = 0;
1268
			for (int i = 0; i < visiblesCount; i++)
1269
				if (candidates[i].isStatic())
1270
					staticCandidates[staticCount++] = candidates[i];
1271
			if (staticCount == 1)
1272
				return staticCandidates[0];
1273
			if (staticCount > 1)
1274
				return mostSpecificMethodBinding(staticCandidates, staticCount, argumentTypes, invocationSite, receiverType);
1275
		}
1276
1260
		MethodBinding mostSpecificMethod = mostSpecificMethodBinding(candidates, visiblesCount, argumentTypes, invocationSite, receiverType);
1277
		MethodBinding mostSpecificMethod = mostSpecificMethodBinding(candidates, visiblesCount, argumentTypes, invocationSite, receiverType);
1261
		if (searchForDefaultAbstractMethod) { // search interfaces for a better match
1278
		if (searchForDefaultAbstractMethod) { // search interfaces for a better match
1262
			if (mostSpecificMethod.isValidBinding())
1279
			if (mostSpecificMethod.isValidBinding())
Lines 1909-1921 Link Here
1909
						if (importBinding.onDemand) {
1926
						if (importBinding.onDemand) {
1910
							if (!skipOnDemand && resolvedImport instanceof ReferenceBinding)
1927
							if (!skipOnDemand && resolvedImport instanceof ReferenceBinding)
1911
								// answers closest approximation, may not check argumentTypes or visibility
1928
								// answers closest approximation, may not check argumentTypes or visibility
1912
								possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite);
1929
								possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite, true);
1913
						} else {
1930
						} else {
1914
							if (resolvedImport instanceof MethodBinding) {
1931
							if (resolvedImport instanceof MethodBinding) {
1915
								MethodBinding staticMethod = (MethodBinding) resolvedImport;
1932
								MethodBinding staticMethod = (MethodBinding) resolvedImport;
1916
								if (CharOperation.equals(staticMethod.selector, selector))
1933
								if (CharOperation.equals(staticMethod.selector, selector))
1917
									// answers closest approximation, may not check argumentTypes or visibility
1934
									// answers closest approximation, may not check argumentTypes or visibility
1918
									possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite);
1935
									possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite, true);
1919
							} else if (resolvedImport instanceof FieldBinding) {
1936
							} else if (resolvedImport instanceof FieldBinding) {
1920
								// check to see if there are also methods with the same name
1937
								// check to see if there are also methods with the same name
1921
								FieldBinding staticField = (FieldBinding) resolvedImport;
1938
								FieldBinding staticField = (FieldBinding) resolvedImport;
Lines 1925-1931 Link Here
1925
									TypeBinding referencedType = getType(importName, importName.length - 1);
1942
									TypeBinding referencedType = getType(importName, importName.length - 1);
1926
									if (referencedType != null)
1943
									if (referencedType != null)
1927
										// answers closest approximation, may not check argumentTypes or visibility
1944
										// answers closest approximation, may not check argumentTypes or visibility
1928
										possible = findMethod((ReferenceBinding) referencedType, selector, argumentTypes, invocationSite);
1945
										possible = findMethod((ReferenceBinding) referencedType, selector, argumentTypes, invocationSite, true);
1929
								}
1946
								}
1930
							}
1947
							}
1931
						}
1948
						}

Return to bug 216930