View | Details | Raw Unified | Return to bug 165900 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/SourceType.java (-1 / +1 lines)
Lines 823-829 Link Here
823
		public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] fieldName, boolean isDeclaration, char[] uniqueKey, int start, int end) {
823
		public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] fieldName, boolean isDeclaration, char[] uniqueKey, int start, int end) {
824
			// ignore
824
			// ignore
825
		}
825
		}
826
		public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, String enclosingDeclaringTypeSignature, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, boolean isConstructor, boolean isDeclaration, char[] uniqueKey, int start, int end) {
826
		public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, String enclosingDeclaringTypeSignature, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, char[][] typeParameterNames, char[][][] typeParameterBoundNames, boolean isConstructor, boolean isDeclaration, char[] uniqueKey, int start, int end) {
827
			// ignore
827
			// ignore
828
		}
828
		}
829
		public void acceptPackage(char[] packageName){
829
		public void acceptPackage(char[] packageName){
(-)model/org/eclipse/jdt/internal/core/SelectionRequestor.java (-50 / +170 lines)
Lines 74-95 Link Here
74
	this.nameLookup = nameLookup;
74
	this.nameLookup = nameLookup;
75
	this.openable = openable;
75
	this.openable = openable;
76
}
76
}
77
/**
77
private void acceptBinaryMethod(
78
 * Resolve the binary method
78
		IType type,
79
 *
79
		IMethod method,
80
 * fix for 1FWFT6Q
80
		char[] uniqueKey,
81
 */
81
		boolean isConstructor) {
82
protected void acceptBinaryMethod(IType type, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, char[] uniqueKey, boolean isConstructor) {
82
	try {
83
	IMethod method= type.getMethod(new String(selector), parameterSignatures);
83
		if(!isConstructor || ((JavaElement)method).getSourceMapper() == null) {
84
	if (method.exists()) {
84
			if (uniqueKey != null) {
85
		try {
85
				ResolvedBinaryMethod resolvedMethod = new ResolvedBinaryMethod(
86
			if(!isConstructor || ((JavaElement)method).getSourceMapper() == null) {
86
						(JavaElement)method.getParent(),
87
				if (uniqueKey != null)
87
						method.getElementName(),
88
					method = new ResolvedBinaryMethod(
88
						method.getParameterTypes(),
89
						new String(uniqueKey));
90
				resolvedMethod.occurrenceCount = method.getOccurrenceCount();
91
				method = resolvedMethod;
92
			}
93
				
94
			addElement(method);
95
			if(SelectionEngine.DEBUG){
96
				System.out.print("SELECTION - accept method("); //$NON-NLS-1$
97
				System.out.print(method.toString());
98
				System.out.println(")"); //$NON-NLS-1$
99
			}
100
		} else {
101
			ISourceRange range = method.getSourceRange();
102
			if (range.getOffset() != -1 && range.getLength() != 0 ) {
103
				if (uniqueKey != null) {
104
					ResolvedBinaryMethod resolvedMethod = new ResolvedBinaryMethod(
89
							(JavaElement)method.getParent(),
105
							(JavaElement)method.getParent(),
90
							method.getElementName(),
106
							method.getElementName(),
91
							method.getParameterTypes(),
107
							method.getParameterTypes(),
92
							new String(uniqueKey));
108
							new String(uniqueKey));
109
					resolvedMethod.occurrenceCount = method.getOccurrenceCount();
110
					method = resolvedMethod;
111
				}
93
				addElement(method);
112
				addElement(method);
94
				if(SelectionEngine.DEBUG){
113
				if(SelectionEngine.DEBUG){
95
					System.out.print("SELECTION - accept method("); //$NON-NLS-1$
114
					System.out.print("SELECTION - accept method("); //$NON-NLS-1$
Lines 97-129 Link Here
97
					System.out.println(")"); //$NON-NLS-1$
116
					System.out.println(")"); //$NON-NLS-1$
98
				}
117
				}
99
			} else {
118
			} else {
100
				ISourceRange range = method.getSourceRange();
119
				// no range was actually found, but a method was originally given -> default constructor
101
				if (range.getOffset() != -1 && range.getLength() != 0 ) {
120
				addElement(type);
102
					if (uniqueKey != null)
121
				if(SelectionEngine.DEBUG){
103
						method = new ResolvedBinaryMethod(
122
					System.out.print("SELECTION - accept type("); //$NON-NLS-1$
104
								(JavaElement)method.getParent(),
123
					System.out.print(type.toString());
105
								method.getElementName(),
124
					System.out.println(")"); //$NON-NLS-1$
106
								method.getParameterTypes(),
125
				}
107
								new String(uniqueKey));
126
			}
108
					addElement(method);
127
		}
109
					if(SelectionEngine.DEBUG){
128
	} catch (JavaModelException e) {
110
						System.out.print("SELECTION - accept method("); //$NON-NLS-1$
129
		// an exception occurs, return nothing
111
						System.out.print(method.toString());
130
	}
112
						System.out.println(")"); //$NON-NLS-1$
131
}
113
					}
132
/**
114
				} else {
133
 * Resolve the binary method
115
					// no range was actually found, but a method was originally given -> default constructor
134
 *
116
					addElement(type);
135
 * fix for 1FWFT6Q
117
					if(SelectionEngine.DEBUG){
136
 */
118
						System.out.print("SELECTION - accept type("); //$NON-NLS-1$
137
protected void acceptBinaryMethod(
119
						System.out.print(type.toString());
138
		IType type,
120
						System.out.println(")"); //$NON-NLS-1$
139
		char[] selector,
140
		char[][] parameterPackageNames,
141
		char[][] parameterTypeNames,
142
		String[] parameterSignatures,
143
		char[][] typeParameterNames,
144
		char[][][] typeParameterBoundNames,
145
		char[] uniqueKey,
146
		boolean isConstructor) {
147
	IMethod method= type.getMethod(new String(selector), parameterSignatures);
148
	
149
	if (method.exists()) {
150
		if (typeParameterNames != null && typeParameterNames.length != 0) {
151
			IMethod[] methods = type.findMethods(method);
152
			if (methods.length > 1) {
153
				for (int i = 0; i < methods.length; i++) {
154
					if (areTypeParametersCompatible(methods[i], typeParameterNames, typeParameterBoundNames)) {
155
						acceptBinaryMethod(type, method, uniqueKey, isConstructor);
121
					}
156
					}
122
				}
157
				}
158
				return;
123
			}
159
			}
124
		} catch (JavaModelException e) {
125
			// an exception occurs, return nothing
126
		}
160
		}
161
		acceptBinaryMethod(type, method, uniqueKey, isConstructor);
127
	}
162
	}
128
}
163
}
129
/**
164
/**
Lines 155-163 Link Here
155
		if(type != null ) {
190
		if(type != null ) {
156
			String key = uniqueKey == null ? type.getKey() : new String(uniqueKey);
191
			String key = uniqueKey == null ? type.getKey() : new String(uniqueKey);
157
			if(type.isBinary()) {
192
			if(type.isBinary()) {
158
				type = new ResolvedBinaryType((JavaElement)type.getParent(), type.getElementName(), key);
193
				ResolvedBinaryType resolvedType = new ResolvedBinaryType((JavaElement)type.getParent(), type.getElementName(), key);
194
				resolvedType.occurrenceCount = type.getOccurrenceCount();
195
				type = resolvedType;
159
			} else {
196
			} else {
160
				type = new ResolvedSourceType((JavaElement)type.getParent(), type.getElementName(), key);
197
				ResolvedSourceType resolvedType = new ResolvedSourceType((JavaElement)type.getParent(), type.getElementName(), key);
198
				resolvedType.occurrenceCount = type.getOccurrenceCount();
199
				type = resolvedType;
161
			}
200
			}
162
		}
201
		}
163
	}
202
	}
Lines 214-228 Link Here
214
			if (field.exists()) {
253
			if (field.exists()) {
215
				if (uniqueKey != null) {
254
				if (uniqueKey != null) {
216
					if(field.isBinary()) {
255
					if(field.isBinary()) {
217
						field = new ResolvedBinaryField(
256
						ResolvedBinaryField resolvedField = new ResolvedBinaryField(
218
								(JavaElement)field.getParent(),
257
								(JavaElement)field.getParent(),
219
								field.getElementName(),
258
								field.getElementName(),
220
								new String(uniqueKey));
259
								new String(uniqueKey));
260
						resolvedField.occurrenceCount = field.getOccurrenceCount();
261
						field = resolvedField;
221
					} else {
262
					} else {
222
						field = new ResolvedSourceField(
263
						ResolvedSourceField resolvedField = new ResolvedSourceField(
223
								(JavaElement)field.getParent(),
264
								(JavaElement)field.getParent(),
224
								field.getElementName(),
265
								field.getElementName(),
225
								new String(uniqueKey));
266
								new String(uniqueKey));
267
						resolvedField.occurrenceCount = field.getOccurrenceCount();
268
						field = resolvedField;
226
					}
269
					}
227
				}
270
				}
228
				addElement(field);
271
				addElement(field);
Lines 250-264 Link Here
250
		if (field.exists()) {
293
		if (field.exists()) {
251
			char[] uniqueKey = fieldBinding.computeUniqueKey();
294
			char[] uniqueKey = fieldBinding.computeUniqueKey();
252
			if(field.isBinary()) {
295
			if(field.isBinary()) {
253
				field = new ResolvedBinaryField(
296
				ResolvedBinaryField resolvedField = new ResolvedBinaryField(
254
						(JavaElement)field.getParent(),
297
						(JavaElement)field.getParent(),
255
						field.getElementName(),
298
						field.getElementName(),
256
						new String(uniqueKey));
299
						new String(uniqueKey));
300
				resolvedField.occurrenceCount = field.getOccurrenceCount();
301
				field = resolvedField;
257
			} else {
302
			} else {
258
				field = new ResolvedSourceField(
303
				ResolvedSourceField resolvedField = new ResolvedSourceField(
259
						(JavaElement)field.getParent(),
304
						(JavaElement)field.getParent(),
260
						field.getElementName(),
305
						field.getElementName(),
261
						new String(uniqueKey));
306
						new String(uniqueKey));
307
				resolvedField.occurrenceCount = field.getOccurrenceCount();
308
				field = resolvedField;
262
			}
309
			}
263
			addElement(field);
310
			addElement(field);
264
			if(SelectionEngine.DEBUG){
311
			if(SelectionEngine.DEBUG){
Lines 277-293 Link Here
277
			
324
			
278
			char[] uniqueKey = methodBinding.computeUniqueKey();
325
			char[] uniqueKey = methodBinding.computeUniqueKey();
279
			if(method.isBinary()) {
326
			if(method.isBinary()) {
280
				res = new ResolvedBinaryMethod(
327
				ResolvedBinaryMethod resolvedRes = new ResolvedBinaryMethod(
281
						(JavaElement)res.getParent(),
328
						(JavaElement)res.getParent(),
282
						method.getElementName(),
329
						method.getElementName(),
283
						method.getParameterTypes(), 
330
						method.getParameterTypes(), 
284
						new String(uniqueKey));
331
						new String(uniqueKey));
332
				resolvedRes.occurrenceCount = method.getOccurrenceCount();
333
				res = resolvedRes;
285
			} else {
334
			} else {
286
				res = new ResolvedSourceMethod(
335
				ResolvedSourceMethod resolvedRes = new ResolvedSourceMethod(
287
						(JavaElement)res.getParent(),
336
						(JavaElement)res.getParent(),
288
						method.getElementName(),
337
						method.getElementName(),
289
						method.getParameterTypes(), 
338
						method.getParameterTypes(), 
290
						new String(uniqueKey));
339
						new String(uniqueKey));
340
				resolvedRes.occurrenceCount = method.getOccurrenceCount();
341
				res = resolvedRes;
291
			}
342
			}
292
			addElement(res);
343
			addElement(res);
293
			if(SelectionEngine.DEBUG){
344
			if(SelectionEngine.DEBUG){
Lines 390-396 Link Here
390
/**
441
/**
391
 * Resolve the method
442
 * Resolve the method
392
 */
443
 */
393
public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, String enclosingDeclaringTypeSignature, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, boolean isConstructor, boolean isDeclaration, char[] uniqueKey, int start, int end) {
444
public void acceptMethod(
445
		char[] declaringTypePackageName,
446
		char[] declaringTypeName,
447
		String enclosingDeclaringTypeSignature, 
448
		char[] selector,
449
		char[][] parameterPackageNames,
450
		char[][] parameterTypeNames,
451
		String[] parameterSignatures,
452
		char[][] typeParameterNames,
453
		char[][][] typeParameterBoundNames,
454
		boolean isConstructor,
455
		boolean isDeclaration,
456
		char[] uniqueKey,
457
		int start,
458
		int end) {
394
	IJavaElement[] previousElement = this.elements;
459
	IJavaElement[] previousElement = this.elements;
395
	int previousElementIndex = this.elementIndex;
460
	int previousElementIndex = this.elementIndex;
396
	this.elements = JavaElement.NO_ELEMENTS;
461
	this.elements = JavaElement.NO_ELEMENTS;
Lines 432-440 Link Here
432
					parameterSignatures[0] = Signature.getTypeErasure(enclosingDeclaringTypeSignature);
497
					parameterSignatures[0] = Signature.getTypeErasure(enclosingDeclaringTypeSignature);
433
				}
498
				}
434
				
499
				
435
				acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, uniqueKey, isConstructor);
500
				acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, typeParameterNames, typeParameterBoundNames, uniqueKey, isConstructor);
436
			} else {
501
			} else {
437
				acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames, uniqueKey);
502
				acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, typeParameterNames, typeParameterBoundNames, uniqueKey);
438
			}
503
			}
439
		}
504
		}
440
	}
505
	}
Lines 469-475 Link Here
469
 *
534
 *
470
 * fix for 1FWFT6Q
535
 * fix for 1FWFT6Q
471
 */
536
 */
472
protected void acceptSourceMethod(IType type, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, char[] uniqueKey) {
537
protected void acceptSourceMethod(
538
		IType type,
539
		char[] selector,
540
		char[][] parameterPackageNames,
541
		char[][] parameterTypeNames,
542
		String[] parameterSignatures,
543
		char[][] typeParameterNames,
544
		char[][][] typeParameterBoundNames,
545
		char[] uniqueKey) {
546
	
473
	String name = new String(selector);
547
	String name = new String(selector);
474
	IMethod[] methods = null;
548
	IMethod[] methods = null;
475
	try {
549
	try {
Lines 478-489 Link Here
478
			if (methods[i].getElementName().equals(name)
552
			if (methods[i].getElementName().equals(name)
479
					&& methods[i].getParameterTypes().length == parameterTypeNames.length) {
553
					&& methods[i].getParameterTypes().length == parameterTypeNames.length) {
480
				IMethod method = methods[i];
554
				IMethod method = methods[i];
481
				if (uniqueKey != null)
555
				if (uniqueKey != null) {
482
					method = new ResolvedSourceMethod(
556
					ResolvedSourceMethod resolvedMethod = new ResolvedSourceMethod(
483
						(JavaElement)method.getParent(),
557
						(JavaElement)method.getParent(),
484
						method.getElementName(),
558
						method.getElementName(),
485
						method.getParameterTypes(),
559
						method.getParameterTypes(),
486
						new String(uniqueKey));
560
						new String(uniqueKey));
561
					resolvedMethod.occurrenceCount = method.getOccurrenceCount();
562
					method = resolvedMethod;
563
				}
487
				addElement(method);
564
				addElement(method);
488
			}
565
			}
489
		}
566
		}
Lines 530-535 Link Here
530
				break;
607
				break;
531
			}
608
			}
532
		}
609
		}
610
		
611
		if (match && !areTypeParametersCompatible(method, typeParameterNames, typeParameterBoundNames)) {
612
			match = false;
613
		}
614
		
533
		if (match) {
615
		if (match) {
534
			addElement(method);
616
			addElement(method);
535
			if(SelectionEngine.DEBUG){
617
			if(SelectionEngine.DEBUG){
Lines 666-672 Link Here
666
	}
748
	}
667
	this.elements[++this.elementIndex] = element;
749
	this.elements[++this.elementIndex] = element;
668
}
750
}
669
751
private boolean areTypeParametersCompatible(IMethod method, char[][] typeParameterNames, char[][][] typeParameterBoundNames) {
752
	try {
753
		ITypeParameter[] typeParameters = method.getTypeParameters();
754
		int length1 = typeParameters == null ? 0 : typeParameters.length;
755
		int length2 = typeParameterNames == null ? 0 : typeParameterNames.length;
756
		if (length1 != length2) {
757
			return false;
758
		} else {
759
			for (int j = 0; j < length1; j++) {
760
				ITypeParameter typeParameter = typeParameters[j];
761
				String typeParameterName = typeParameter.getElementName();
762
				if (!typeParameterName.equals(new String(typeParameterNames[j]))) {
763
					return false;
764
				}
765
				
766
				String[] bounds = typeParameter.getBounds();
767
				int boundCount = typeParameterBoundNames[j] == null ? 0 : typeParameterBoundNames[j].length;
768
				
769
				if (bounds.length != boundCount) {
770
					return false;
771
				} else {
772
					for (int k = 0; k < boundCount; k++) {
773
						String simpleName = Signature.getSimpleName(bounds[k]);
774
						int index = simpleName.indexOf('<');
775
						if (index != -1) {
776
							simpleName = simpleName.substring(0, index);
777
						}
778
						if (!simpleName.equals(new String(typeParameterBoundNames[j][k]))) {
779
							return false;
780
						}
781
					}
782
				}
783
			}
784
		}
785
	} catch (JavaModelException e) {
786
		return false;
787
	}
788
	return true;
789
}
670
/*
790
/*
671
 * findLocalElement() cannot find local variable
791
 * findLocalElement() cannot find local variable
672
 */
792
 */
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-5 / +5 lines)
Lines 1230-1236 Link Here
1230
				if (current instanceof ParameterizedMethodBinding)
1230
				if (current instanceof ParameterizedMethodBinding)
1231
					for (int j = i + 1; j < visiblesCount; j++)
1231
					for (int j = i + 1; j < visiblesCount; j++)
1232
						if (current.declaringClass == candidates[j].declaringClass && current.areParametersEqual(candidates[j]))
1232
						if (current.declaringClass == candidates[j].declaringClass && current.areParametersEqual(candidates[j]))
1233
							return new ProblemMethodBinding(candidates[i].selector, candidates[i].parameters, ProblemReasons.Ambiguous);
1233
							return new ProblemMethodBinding(candidates[i], candidates[i].selector, candidates[i].parameters, ProblemReasons.Ambiguous);
1234
			}
1234
			}
1235
		}
1235
		}
1236
1236
Lines 3138-3144 Link Here
3138
			return method;
3138
			return method;
3139
		}
3139
		}
3140
		if (problemMethod == null)
3140
		if (problemMethod == null)
3141
			return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3141
			return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3142
		return problemMethod;
3142
		return problemMethod;
3143
	}
3143
	}
3144
	
3144
	
Lines 3184-3190 Link Here
3184
			return method;
3184
			return method;
3185
		}
3185
		}
3186
		if (problemMethod == null)
3186
		if (problemMethod == null)
3187
			return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3187
			return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3188
		return problemMethod;
3188
		return problemMethod;
3189
	}
3189
	}
3190
3190
Lines 3251-3257 Link Here
3251
				}
3251
				}
3252
			}
3252
			}
3253
		} else if (count == 0) {
3253
		} else if (count == 0) {
3254
			return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3254
			return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3255
		}
3255
		}
3256
3256
3257
		// found several methods that are mutually acceptable -> must be equal
3257
		// found several methods that are mutually acceptable -> must be equal
Lines 3389-3395 Link Here
3389
		}
3389
		}
3390
3390
3391
		// if all moreSpecific methods are equal then see if duplicates exist because of substitution
3391
		// if all moreSpecific methods are equal then see if duplicates exist because of substitution
3392
		return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3392
		return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3393
	}
3393
	}
3394
3394
3395
	public final ClassScope outerMostClassScope() {
3395
	public final ClassScope outerMostClassScope() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java (-1 / +1 lines)
Lines 31-37 Link Here
31
public ProblemMethodBinding(MethodBinding closestMatch, char[] selector, TypeBinding[] args, int problemReason) {
31
public ProblemMethodBinding(MethodBinding closestMatch, char[] selector, TypeBinding[] args, int problemReason) {
32
	this(selector, args, problemReason);
32
	this(selector, args, problemReason);
33
	this.closestMatch = closestMatch;
33
	this.closestMatch = closestMatch;
34
	if (closestMatch != null) this.declaringClass = closestMatch.declaringClass;
34
	if (closestMatch != null && problemReason != ProblemReasons.Ambiguous) this.declaringClass = closestMatch.declaringClass;
35
}
35
}
36
/* API
36
/* API
37
* Answer the problem id associated with the receiver.
37
* Answer the problem id associated with the receiver.
(-)codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java (+2 lines)
Lines 160-165 Link Here
160
		char[][] parameterPackageNames,
160
		char[][] parameterPackageNames,
161
		char[][] parameterTypeNames,
161
		char[][] parameterTypeNames,
162
		String[] parameterSignatures,
162
		String[] parameterSignatures,
163
		char[][] typeParameterNames,
164
		char[][][] typeParameterBoundNames,
163
		boolean isConstructor,
165
		boolean isConstructor,
164
		boolean isDeclaration,
166
		boolean isDeclaration,
165
		char[] uniqueKey,
167
		char[] uniqueKey,
(-)codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java (+29 lines)
Lines 873-878 Link Here
873
						parameterSignatures[i] = new String(getSignature(parameterTypes[i])).replace('/', '.');
873
						parameterSignatures[i] = new String(getSignature(parameterTypes[i])).replace('/', '.');
874
					}
874
					}
875
					
875
					
876
					TypeVariableBinding[] typeVariables = methodBinding.original().typeVariables;
877
					length = typeVariables == null ? 0 : typeVariables.length;
878
					char[][] typeParameterNames = new char[length][];
879
					char[][][] typeParameterBoundNames = new char[length][][];
880
					for (int i = 0; i < length; i++) {
881
						TypeVariableBinding typeVariable = typeVariables[i];
882
						typeParameterNames[i] = typeVariable.sourceName;
883
						if (typeVariable.firstBound == null) {
884
							typeParameterBoundNames[i] = new char[0][];
885
						} else if (typeVariable.firstBound == typeVariable.superclass) {
886
							int boundCount = 1 + (typeVariable.superInterfaces == null ? 0 : typeVariable.superInterfaces.length);
887
							typeParameterBoundNames[i] = new char[boundCount][];
888
							typeParameterBoundNames[i][0] = typeVariable.superclass.sourceName;
889
							for (int j = 1; j < boundCount; j++) {
890
								typeParameterBoundNames[i][j] = typeVariables[i].superInterfaces[j - 1].sourceName;
891
							}
892
						} else {
893
							int boundCount = typeVariable.superInterfaces == null ? 0 : typeVariable.superInterfaces.length;
894
							typeParameterBoundNames[i] = new char[boundCount][];
895
							for (int j = 0; j < boundCount; j++) {
896
								typeParameterBoundNames[i][j] = typeVariables[i].superInterfaces[j].sourceName;
897
							}
898
						}
899
					}
900
					
876
					ReferenceBinding declaringClass = methodBinding.declaringClass;
901
					ReferenceBinding declaringClass = methodBinding.declaringClass;
877
					if (isLocal(declaringClass) && this.requestor instanceof SelectionRequestor) {
902
					if (isLocal(declaringClass) && this.requestor instanceof SelectionRequestor) {
878
						((SelectionRequestor)this.requestor).acceptLocalMethod(methodBinding);
903
						((SelectionRequestor)this.requestor).acceptLocalMethod(methodBinding);
Lines 887-892 Link Here
887
							parameterPackageNames,
912
							parameterPackageNames,
888
							parameterTypeNames,
913
							parameterTypeNames,
889
							parameterSignatures,
914
							parameterSignatures,
915
							typeParameterNames,
916
							typeParameterBoundNames,
890
							methodBinding.isConstructor(), 
917
							methodBinding.isConstructor(), 
891
							isDeclaration,
918
							isDeclaration,
892
							methodBinding.computeUniqueKey(),
919
							methodBinding.computeUniqueKey(),
Lines 1239-1244 Link Here
1239
					null, // SelectionRequestor does not need of parameters type for method declaration
1266
					null, // SelectionRequestor does not need of parameters type for method declaration
1240
					null, // SelectionRequestor does not need of parameters type for method declaration
1267
					null, // SelectionRequestor does not need of parameters type for method declaration
1241
					null, // SelectionRequestor does not need of parameters type for method declaration
1268
					null, // SelectionRequestor does not need of parameters type for method declaration
1269
					null, // SelectionRequestor does not need of type parameters name for method declaration
1270
					null, // SelectionRequestor does not need of type parameters bounds for method declaration
1242
					method.isConstructor(),
1271
					method.isConstructor(),
1243
					true,
1272
					true,
1244
					method.binding != null ? method.binding.computeUniqueKey() : null,
1273
					method.binding != null ? method.binding.computeUniqueKey() : null,
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java (-2 / +2 lines)
Lines 285-292 Link Here
285
		public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, boolean isDeclaration, char[] uniqueKey, int start, int end) {
285
		public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, boolean isDeclaration, char[] uniqueKey, int start, int end) {
286
			originalRequestor.acceptField(declaringTypePackageName, declaringTypeName, name, isDeclaration, uniqueKey, start, end);
286
			originalRequestor.acceptField(declaringTypePackageName, declaringTypeName, name, isDeclaration, uniqueKey, start, end);
287
		}
287
		}
288
		public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, String enclosingDeclaringTypeSignature, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, boolean isConstructor, boolean isDeclaration, char[] uniqueKey, int start, int end) {
288
		public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, String enclosingDeclaringTypeSignature, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, char[][] typeParameterNames, char[][][] typeParameterBoundNames, boolean isConstructor, boolean isDeclaration, char[] uniqueKey, int start, int end) {
289
			originalRequestor.acceptMethod(declaringTypePackageName, declaringTypeName, enclosingDeclaringTypeSignature, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, isConstructor, isDeclaration, uniqueKey, start, end);
289
			originalRequestor.acceptMethod(declaringTypePackageName, declaringTypeName, enclosingDeclaringTypeSignature, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, typeParameterNames, typeParameterBoundNames, isConstructor, isDeclaration, uniqueKey, start, end);
290
		}
290
		}
291
		public void acceptPackage(char[] packageName) {
291
		public void acceptPackage(char[] packageName) {
292
			originalRequestor.acceptPackage(packageName);
292
			originalRequestor.acceptPackage(packageName);
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java (-2 / +2 lines)
Lines 312-318 Link Here
312
				if (visibleField == null)
312
				if (visibleField == null)
313
					visibleField = field;
313
					visibleField = field;
314
				else
314
				else
315
					return new ProblemFieldBinding(visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
315
					return new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
316
			} else {
316
			} else {
317
				notVisible = true;
317
				notVisible = true;
318
			}
318
			}
Lines 334-340 Link Here
334
						if (visibleField == null) {
334
						if (visibleField == null) {
335
							visibleField = field;
335
							visibleField = field;
336
						} else {
336
						} else {
337
							ambiguous = new ProblemFieldBinding(visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
337
							ambiguous = new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
338
							break done;
338
							break done;
339
						}
339
						}
340
					} else {
340
					} else {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (+1 lines)
Lines 403-408 Link Here
403
		MethodBinding closestMatch = ((ProblemMethodBinding)binding).closestMatch;
403
		MethodBinding closestMatch = ((ProblemMethodBinding)binding).closestMatch;
404
		switch (this.binding.problemId()) {
404
		switch (this.binding.problemId()) {
405
			case ProblemReasons.Ambiguous :
405
			case ProblemReasons.Ambiguous :
406
				break; // no resilience on ambiguous
406
			case ProblemReasons.NotVisible :
407
			case ProblemReasons.NotVisible :
407
			case ProblemReasons.NonStaticReferenceInConstructorInvocation :
408
			case ProblemReasons.NonStaticReferenceInConstructorInvocation :
408
			case ProblemReasons.NonStaticReferenceInStaticContext :
409
			case ProblemReasons.NonStaticReferenceInStaticContext :
(-)src/org/eclipse/jdt/core/tests/model/ResolveTests.java (+29 lines)
Lines 76-81 Link Here
76
		elements
76
		elements
77
	);
77
	);
78
}
78
}
79
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900
80
public void testAmbiguousMethod1() throws JavaModelException {
81
	this.workingCopies = new ICompilationUnit[1];
82
	this.workingCopies[0] = getWorkingCopy(
83
		"/Resolve/src/test/Test.java",
84
		"package test;\n"+
85
		"public class Test {\n" + 
86
		"  void foo(Test1 t) {}\n" + 
87
		"  void foo(Test2 t) {}\n" + 
88
		"  void bar(Object o) {\n" + 
89
		"    foo(o);\n" + 
90
		"  }\n" + 
91
		"}\n" + 
92
		"class Test1 {\n" + 
93
		"}\n" + 
94
		"class Test2 {\n" + 
95
		"}");
96
97
	String str = this.workingCopies[0].getSource();
98
	int start = str.lastIndexOf("foo(o)");
99
	int length = "foo".length();
100
	IJavaElement[] elements =  this.workingCopies[0].codeSelect(start, length, this.wcOwner);
101
	
102
	assertElementsEqual(
103
			"Unexpected elements",
104
			"foo(Test1) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]",
105
			elements
106
		);
107
}
79
/**
108
/**
80
 * Resolve an argument name
109
 * Resolve an argument name
81
 */
110
 */
(-)src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java (+122 lines)
Lines 2285-2288 Link Here
2285
		deleteProject("P");
2285
		deleteProject("P");
2286
	}
2286
	}
2287
}
2287
}
2288
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900
2289
public void test103() throws JavaModelException {
2290
	this.workingCopies = new ICompilationUnit[1];
2291
	this.workingCopies[0] = getWorkingCopy(
2292
		"/Resolve/src/test/Test.java",
2293
		"package test;\n"+
2294
		"public class Test {\n" + 
2295
		"  <T extends Test1> void foo(T t) {}\n" + 
2296
		"  <T extends Test2> void foo(T t) {}\n" + 
2297
		"  void bar(Object o) {\n" + 
2298
		"    foo(o);\n" + 
2299
		"  }\n" + 
2300
		"}\n" + 
2301
		"class Test1 {\n" + 
2302
		"}\n" + 
2303
		"class Test2 {\n" + 
2304
		"}");
2305
2306
	String str = this.workingCopies[0].getSource();
2307
	int start = str.lastIndexOf("foo(o)");
2308
	int length = "foo".length();
2309
	IJavaElement[] elements =  this.workingCopies[0].codeSelect(start, length, this.wcOwner);
2310
	
2311
	assertElementsEqual(
2312
			"Unexpected elements",
2313
			"foo(T) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]",
2314
			elements
2315
		);
2316
}
2317
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900
2318
public void test104() throws JavaModelException {
2319
	this.workingCopies = new ICompilationUnit[1];
2320
	this.workingCopies[0] = getWorkingCopy(
2321
		"/Resolve/src/test/Test.java",
2322
		"package test;\n"+
2323
		"public class Test {\n" + 
2324
		"  <T extends Test1> T foo(Test3<T> t) {return null;}\n" + 
2325
		"  <T extends Test2> T foo(Test3<T> t) {return null;}\n" + 
2326
		"  void bar(Object o) {\n" + 
2327
		"    foo(o);\n" + 
2328
		"  }\n" + 
2329
		"}\n" + 
2330
		"class Test1 {\n" + 
2331
		"}\n" + 
2332
		"class Test2 {\n" + 
2333
		"}\n" + 
2334
		"class Test3 <U> {\n" + 
2335
		"}");
2336
2337
	String str = this.workingCopies[0].getSource();
2338
	int start = str.lastIndexOf("foo(o)");
2339
	int length = "foo".length();
2340
	IJavaElement[] elements =  this.workingCopies[0].codeSelect(start, length, this.wcOwner);
2341
	
2342
	assertElementsEqual(
2343
			"Unexpected elements",
2344
			"foo(Test3<T>) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]",
2345
			elements
2346
		);
2347
}
2348
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900
2349
public void test105() throws JavaModelException {
2350
	this.workingCopies = new ICompilationUnit[1];
2351
	this.workingCopies[0] = getWorkingCopy(
2352
		"/Resolve/src/test/Test.java",
2353
		"package test;\n"+
2354
		"public class Test {\n" + 
2355
		"  <T extends Test1> T foo(Test3<T> t) {return null;}\n" + 
2356
		"  <T extends Test2> T foo(Test3<T> t) {return null;}\n" + 
2357
		"  void bar(Test3 o) {\n" + 
2358
		"    foo(o);\n" + 
2359
		"  }\n" + 
2360
		"}\n" + 
2361
		"class Test1 {\n" + 
2362
		"}\n" + 
2363
		"class Test2 {\n" + 
2364
		"}\n" + 
2365
		"class Test3 <U> {\n" + 
2366
		"}");
2367
2368
	String str = this.workingCopies[0].getSource();
2369
	int start = str.lastIndexOf("foo(o)");
2370
	int length = "foo".length();
2371
	IJavaElement[] elements =  this.workingCopies[0].codeSelect(start, length, this.wcOwner);
2372
	
2373
	assertElementsEqual(
2374
			"Unexpected elements",
2375
			"foo(Test3<T>) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]",
2376
			elements
2377
		);
2378
}
2379
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900
2380
public void test106() throws JavaModelException {
2381
	this.workingCopies = new ICompilationUnit[1];
2382
	this.workingCopies[0] = getWorkingCopy(
2383
		"/Resolve/src/test/Test.java",
2384
		"package test;\n"+
2385
		"public class Test {\n" + 
2386
		"  <T extends Test1> T foo(Test3<T> t) {return null;}\n" + 
2387
		"  <T extends Test2> T foo(Test3<T> t) {return null;}\n" + 
2388
		"  void bar(Test3<Object> o) {\n" + 
2389
		"    foo(o);\n" + 
2390
		"  }\n" + 
2391
		"}\n" + 
2392
		"class Test1 {\n" + 
2393
		"}\n" + 
2394
		"class Test2 {\n" + 
2395
		"}\n" + 
2396
		"class Test3 <U> {\n" + 
2397
		"}");
2398
2399
	String str = this.workingCopies[0].getSource();
2400
	int start = str.lastIndexOf("foo(o)");
2401
	int length = "foo".length();
2402
	IJavaElement[] elements =  this.workingCopies[0].codeSelect(start, length, this.wcOwner);
2403
	
2404
	assertElementsEqual(
2405
			"Unexpected elements",
2406
			"foo(Test3<T>) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]",
2407
			elements
2408
		);
2409
}
2288
}
2410
}
(-)src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java (-1 lines)
Lines 980-986 Link Here
980
		int[] selectionPositions = selectionInfo(workingCopies[0], "getMax", 1);
980
		int[] selectionPositions = selectionInfo(workingCopies[0], "getMax", 1);
981
		IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0);
981
		IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0);
982
		assertElementsEqual("Invalid selection(s)",
982
		assertElementsEqual("Invalid selection(s)",
983
			"getMax(A<T>) [in X [in [Working copy] Test.java [in b165794 [in <project root> [in Tests]]]]]\n" + 
984
			"getMax(A<T>) [in X [in [Working copy] Test.java [in b165794 [in <project root> [in Tests]]]]]",
983
			"getMax(A<T>) [in X [in [Working copy] Test.java [in b165794 [in <project root> [in Tests]]]]]",
985
			elements
984
			elements
986
		);
985
		);

Return to bug 165900