Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 354766 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/text/java/MethodProposalInfo.java (-9 / +17 lines)
Lines 14-19 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.jdt.core.CompletionProposal;
16
import org.eclipse.jdt.core.CompletionProposal;
17
import org.eclipse.jdt.core.Flags;
17
import org.eclipse.jdt.core.IJavaProject;
18
import org.eclipse.jdt.core.IJavaProject;
18
import org.eclipse.jdt.core.IMember;
19
import org.eclipse.jdt.core.IMember;
19
import org.eclipse.jdt.core.IMethod;
20
import org.eclipse.jdt.core.IMethod;
Lines 90-96 Link Here
90
	 */
91
	 */
91
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type) throws JavaModelException {
92
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type) throws JavaModelException {
92
		Map<String, char[]> typeVariables= computeTypeVariables(type);
93
		Map<String, char[]> typeVariables= computeTypeVariables(type);
93
		return findMethod(name, paramTypes, isConstructor, type.getMethods(), typeVariables);
94
		return findMethod(name, paramTypes, isConstructor, type, typeVariables);
94
	}
95
	}
95
96
96
	/**
97
	/**
Lines 142-155 Link Here
142
	 * @param paramTypes The type signatures of the parameters e.g.
143
	 * @param paramTypes The type signatures of the parameters e.g.
143
	 *        <code>{"QString;","I"}</code>
144
	 *        <code>{"QString;","I"}</code>
144
	 * @param isConstructor If the method is a constructor
145
	 * @param isConstructor If the method is a constructor
145
	 * @param methods The methods to search in
146
	 * @param type the given type in which to search for methods
146
	 * @param typeVariables a map from type variables to concretely used types
147
	 * @param typeVariables a map from type variables to concretely used types
147
	 * @return The found method or <code>null</code>, if nothing found
148
	 * @return The found method or <code>null</code>, if nothing found
148
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
149
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
149
	 */
150
	 */
150
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IMethod[] methods, Map<String, char[]> typeVariables) throws JavaModelException {
151
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type, Map<String, char[]> typeVariables) throws JavaModelException {
152
		IMethod[] methods = type.getMethods();
151
		for (int i= methods.length - 1; i >= 0; i--) {
153
		for (int i= methods.length - 1; i >= 0; i--) {
152
			if (isSameMethodSignature(name, paramTypes, isConstructor, methods[i], typeVariables)) {
154
			if (isSameMethodSignature(name, paramTypes, isConstructor, methods[i], typeVariables, type)) {
153
				return methods[i];
155
				return methods[i];
154
			}
156
			}
155
		}
157
		}
Lines 167-181 Link Here
167
	 * @param isConstructor Specifies if the method is a constructor
169
	 * @param isConstructor Specifies if the method is a constructor
168
	 * @param method the method to be compared with this info's method
170
	 * @param method the method to be compared with this info's method
169
	 * @param typeVariables a map from type variables to types
171
	 * @param typeVariables a map from type variables to types
172
	 * @param type the given type that declares the method
170
	 * @return Returns <code>true</code> if the method has the given name and
173
	 * @return Returns <code>true</code> if the method has the given name and
171
	 *         parameter types and constructor state.
174
	 *         parameter types and constructor state.
172
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
175
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
173
	 */
176
	 */
174
	private boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod method, Map<String, char[]> typeVariables) throws JavaModelException {
177
	private boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod method, Map<String, char[]> typeVariables, IType type) throws JavaModelException {
175
		if (isConstructor || name.equals(method.getElementName())) {
178
		if (isConstructor || name.equals(method.getElementName())) {
176
			if (isConstructor == method.isConstructor()) {
179
			if (isConstructor == method.isConstructor()) {
177
				String[] otherParams= method.getParameterTypes(); // types may be type variables
180
				String[] otherParams= method.getParameterTypes(); // types may be type variables
178
				if (paramTypes.length == otherParams.length) {
181
				boolean isBinaryConstructorForNonStaticMemberClass=
182
						method.isBinary()
183
						&& type.isMember()
184
						&& !Flags.isStatic(type.getFlags());
185
				int syntheticParameterCorrection= isBinaryConstructorForNonStaticMemberClass ? 1 : 0;
186
				if (paramTypes.length == otherParams.length - syntheticParameterCorrection) {
179
					fFallbackMatch= method;
187
					fFallbackMatch= method;
180
					String signature= method.getSignature();
188
					String signature= method.getSignature();
181
					String[] otherParamsFromSignature= Signature.getParameterTypes(signature); // types are resolved / upper-bounded
189
					String[] otherParamsFromSignature= Signature.getParameterTypes(signature); // types are resolved / upper-bounded
Lines 183-191 Link Here
183
					// not yet bound when proposing a method
191
					// not yet bound when proposing a method
184
					for (int i= 0; i < paramTypes.length; i++) {
192
					for (int i= 0; i < paramTypes.length; i++) {
185
						String ourParamName= computeSimpleTypeName(paramTypes[i], typeVariables);
193
						String ourParamName= computeSimpleTypeName(paramTypes[i], typeVariables);
186
						String otherParamName1= computeSimpleTypeName(otherParams[i], typeVariables);
194
						String otherParamName1= computeSimpleTypeName(otherParams[i + syntheticParameterCorrection], typeVariables);
187
						String otherParamName2= computeSimpleTypeName(otherParamsFromSignature[i], typeVariables);
195
						String otherParamName2= computeSimpleTypeName(otherParamsFromSignature[i + syntheticParameterCorrection], typeVariables);
188
196
	
189
						if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) {
197
						if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) {
190
							return false;
198
							return false;
191
						}
199
						}

Return to bug 354766