### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ResolveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java,v retrieving revision 1.70 diff -u -r1.70 ResolveTests.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 24 Nov 2006 11:31:14 -0000 1.70 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 7 Dec 2006 14:29:55 -0000 @@ -76,6 +76,35 @@ elements ); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900 +public void testAmbiguousMethod1() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " void foo(Test1 t) {}\n" + + " void foo(Test2 t) {}\n" + + " void bar(Object o) {\n" + + " foo(o);\n" + + " }\n" + + "}\n" + + "class Test1 {\n" + + "}\n" + + "class Test2 {\n" + + "}"); + + String str = this.workingCopies[0].getSource(); + int start = str.lastIndexOf("foo(o)"); + int length = "foo".length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); + + assertElementsEqual( + "Unexpected elements", + "foo(Test1) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]", + elements + ); +} /** * Resolve an argument name */ Index: src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java,v retrieving revision 1.52 diff -u -r1.52 ResolveTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 11 Apr 2006 10:10:45 -0000 1.52 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 7 Dec 2006 14:29:55 -0000 @@ -2285,4 +2285,126 @@ deleteProject("P"); } } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900 +public void test103() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " void foo(T t) {}\n" + + " void foo(T t) {}\n" + + " void bar(Object o) {\n" + + " foo(o);\n" + + " }\n" + + "}\n" + + "class Test1 {\n" + + "}\n" + + "class Test2 {\n" + + "}"); + + String str = this.workingCopies[0].getSource(); + int start = str.lastIndexOf("foo(o)"); + int length = "foo".length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); + + assertElementsEqual( + "Unexpected elements", + "foo(T) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]", + elements + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900 +public void test104() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " T foo(Test3 t) {return null;}\n" + + " T foo(Test3 t) {return null;}\n" + + " void bar(Object o) {\n" + + " foo(o);\n" + + " }\n" + + "}\n" + + "class Test1 {\n" + + "}\n" + + "class Test2 {\n" + + "}\n" + + "class Test3 {\n" + + "}"); + + String str = this.workingCopies[0].getSource(); + int start = str.lastIndexOf("foo(o)"); + int length = "foo".length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); + + assertElementsEqual( + "Unexpected elements", + "foo(Test3) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]", + elements + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900 +public void test105() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " T foo(Test3 t) {return null;}\n" + + " T foo(Test3 t) {return null;}\n" + + " void bar(Test3 o) {\n" + + " foo(o);\n" + + " }\n" + + "}\n" + + "class Test1 {\n" + + "}\n" + + "class Test2 {\n" + + "}\n" + + "class Test3 {\n" + + "}"); + + String str = this.workingCopies[0].getSource(); + int start = str.lastIndexOf("foo(o)"); + int length = "foo".length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); + + assertElementsEqual( + "Unexpected elements", + "foo(Test3) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]", + elements + ); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165900 +public void test106() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " T foo(Test3 t) {return null;}\n" + + " T foo(Test3 t) {return null;}\n" + + " void bar(Test3 o) {\n" + + " foo(o);\n" + + " }\n" + + "}\n" + + "class Test1 {\n" + + "}\n" + + "class Test2 {\n" + + "}\n" + + "class Test3 {\n" + + "}"); + + String str = this.workingCopies[0].getSource(); + int start = str.lastIndexOf("foo(o)"); + int length = "foo".length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); + + assertElementsEqual( + "Unexpected elements", + "foo(Test3) [in Test [in [Working copy] Test.java [in test [in src [in Resolve]]]]]", + elements + ); +} } Index: src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java,v retrieving revision 1.9 diff -u -r1.9 SelectionJavadocModelTests.java --- src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java 25 Nov 2006 19:50:11 -0000 1.9 +++ src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java 7 Dec 2006 14:29:55 -0000 @@ -980,7 +980,6 @@ int[] selectionPositions = selectionInfo(workingCopies[0], "getMax", 1); IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0); assertElementsEqual("Invalid selection(s)", - "getMax(A) [in X [in [Working copy] Test.java [in b165794 [in [in Tests]]]]]\n" + "getMax(A) [in X [in [Working copy] Test.java [in b165794 [in [in Tests]]]]]", elements ); #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/SourceType.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java,v retrieving revision 1.139 diff -u -r1.139 SourceType.java --- model/org/eclipse/jdt/internal/core/SourceType.java 28 Jun 2006 08:52:07 -0000 1.139 +++ model/org/eclipse/jdt/internal/core/SourceType.java 7 Dec 2006 14:30:01 -0000 @@ -823,7 +823,7 @@ public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] fieldName, boolean isDeclaration, char[] uniqueKey, int start, int end) { // ignore } - 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) { + 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) { // ignore } public void acceptPackage(char[] packageName){ Index: model/org/eclipse/jdt/internal/core/SelectionRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java,v retrieving revision 1.67 diff -u -r1.67 SelectionRequestor.java --- model/org/eclipse/jdt/internal/core/SelectionRequestor.java 4 Apr 2006 13:33:40 -0000 1.67 +++ model/org/eclipse/jdt/internal/core/SelectionRequestor.java 7 Dec 2006 14:30:01 -0000 @@ -74,22 +74,41 @@ this.nameLookup = nameLookup; this.openable = openable; } -/** - * Resolve the binary method - * - * fix for 1FWFT6Q - */ -protected void acceptBinaryMethod(IType type, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, char[] uniqueKey, boolean isConstructor) { - IMethod method= type.getMethod(new String(selector), parameterSignatures); - if (method.exists()) { - try { - if(!isConstructor || ((JavaElement)method).getSourceMapper() == null) { - if (uniqueKey != null) - method = new ResolvedBinaryMethod( +private void acceptBinaryMethod( + IType type, + IMethod method, + char[] uniqueKey, + boolean isConstructor) { + try { + if(!isConstructor || ((JavaElement)method).getSourceMapper() == null) { + if (uniqueKey != null) { + ResolvedBinaryMethod resolvedMethod = new ResolvedBinaryMethod( + (JavaElement)method.getParent(), + method.getElementName(), + method.getParameterTypes(), + new String(uniqueKey)); + resolvedMethod.occurrenceCount = method.getOccurrenceCount(); + method = resolvedMethod; + } + + addElement(method); + if(SelectionEngine.DEBUG){ + System.out.print("SELECTION - accept method("); //$NON-NLS-1$ + System.out.print(method.toString()); + System.out.println(")"); //$NON-NLS-1$ + } + } else { + ISourceRange range = method.getSourceRange(); + if (range.getOffset() != -1 && range.getLength() != 0 ) { + if (uniqueKey != null) { + ResolvedBinaryMethod resolvedMethod = new ResolvedBinaryMethod( (JavaElement)method.getParent(), method.getElementName(), method.getParameterTypes(), new String(uniqueKey)); + resolvedMethod.occurrenceCount = method.getOccurrenceCount(); + method = resolvedMethod; + } addElement(method); if(SelectionEngine.DEBUG){ System.out.print("SELECTION - accept method("); //$NON-NLS-1$ @@ -97,33 +116,49 @@ System.out.println(")"); //$NON-NLS-1$ } } else { - ISourceRange range = method.getSourceRange(); - if (range.getOffset() != -1 && range.getLength() != 0 ) { - if (uniqueKey != null) - method = new ResolvedBinaryMethod( - (JavaElement)method.getParent(), - method.getElementName(), - method.getParameterTypes(), - new String(uniqueKey)); - addElement(method); - if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(method.toString()); - System.out.println(")"); //$NON-NLS-1$ - } - } else { - // no range was actually found, but a method was originally given -> default constructor - addElement(type); - if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + // no range was actually found, but a method was originally given -> default constructor + addElement(type); + if(SelectionEngine.DEBUG){ + System.out.print("SELECTION - accept type("); //$NON-NLS-1$ + System.out.print(type.toString()); + System.out.println(")"); //$NON-NLS-1$ + } + } + } + } catch (JavaModelException e) { + // an exception occurs, return nothing + } +} +/** + * Resolve the binary method + * + * fix for 1FWFT6Q + */ +protected void acceptBinaryMethod( + IType type, + char[] selector, + char[][] parameterPackageNames, + char[][] parameterTypeNames, + String[] parameterSignatures, + char[][] typeParameterNames, + char[][][] typeParameterBoundNames, + char[] uniqueKey, + boolean isConstructor) { + IMethod method= type.getMethod(new String(selector), parameterSignatures); + + if (method.exists()) { + if (typeParameterNames != null && typeParameterNames.length != 0) { + IMethod[] methods = type.findMethods(method); + if (methods.length > 1) { + for (int i = 0; i < methods.length; i++) { + if (areTypeParametersCompatible(methods[i], typeParameterNames, typeParameterBoundNames)) { + acceptBinaryMethod(type, method, uniqueKey, isConstructor); } } + return; } - } catch (JavaModelException e) { - // an exception occurs, return nothing } + acceptBinaryMethod(type, method, uniqueKey, isConstructor); } } /** @@ -155,9 +190,13 @@ if(type != null ) { String key = uniqueKey == null ? type.getKey() : new String(uniqueKey); if(type.isBinary()) { - type = new ResolvedBinaryType((JavaElement)type.getParent(), type.getElementName(), key); + ResolvedBinaryType resolvedType = new ResolvedBinaryType((JavaElement)type.getParent(), type.getElementName(), key); + resolvedType.occurrenceCount = type.getOccurrenceCount(); + type = resolvedType; } else { - type = new ResolvedSourceType((JavaElement)type.getParent(), type.getElementName(), key); + ResolvedSourceType resolvedType = new ResolvedSourceType((JavaElement)type.getParent(), type.getElementName(), key); + resolvedType.occurrenceCount = type.getOccurrenceCount(); + type = resolvedType; } } } @@ -214,15 +253,19 @@ if (field.exists()) { if (uniqueKey != null) { if(field.isBinary()) { - field = new ResolvedBinaryField( + ResolvedBinaryField resolvedField = new ResolvedBinaryField( (JavaElement)field.getParent(), field.getElementName(), new String(uniqueKey)); + resolvedField.occurrenceCount = field.getOccurrenceCount(); + field = resolvedField; } else { - field = new ResolvedSourceField( + ResolvedSourceField resolvedField = new ResolvedSourceField( (JavaElement)field.getParent(), field.getElementName(), new String(uniqueKey)); + resolvedField.occurrenceCount = field.getOccurrenceCount(); + field = resolvedField; } } addElement(field); @@ -250,15 +293,19 @@ if (field.exists()) { char[] uniqueKey = fieldBinding.computeUniqueKey(); if(field.isBinary()) { - field = new ResolvedBinaryField( + ResolvedBinaryField resolvedField = new ResolvedBinaryField( (JavaElement)field.getParent(), field.getElementName(), new String(uniqueKey)); + resolvedField.occurrenceCount = field.getOccurrenceCount(); + field = resolvedField; } else { - field = new ResolvedSourceField( + ResolvedSourceField resolvedField = new ResolvedSourceField( (JavaElement)field.getParent(), field.getElementName(), new String(uniqueKey)); + resolvedField.occurrenceCount = field.getOccurrenceCount(); + field = resolvedField; } addElement(field); if(SelectionEngine.DEBUG){ @@ -277,17 +324,21 @@ char[] uniqueKey = methodBinding.computeUniqueKey(); if(method.isBinary()) { - res = new ResolvedBinaryMethod( + ResolvedBinaryMethod resolvedRes = new ResolvedBinaryMethod( (JavaElement)res.getParent(), method.getElementName(), method.getParameterTypes(), new String(uniqueKey)); + resolvedRes.occurrenceCount = method.getOccurrenceCount(); + res = resolvedRes; } else { - res = new ResolvedSourceMethod( + ResolvedSourceMethod resolvedRes = new ResolvedSourceMethod( (JavaElement)res.getParent(), method.getElementName(), method.getParameterTypes(), new String(uniqueKey)); + resolvedRes.occurrenceCount = method.getOccurrenceCount(); + res = resolvedRes; } addElement(res); if(SelectionEngine.DEBUG){ @@ -390,7 +441,21 @@ /** * Resolve the method */ -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) { +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) { IJavaElement[] previousElement = this.elements; int previousElementIndex = this.elementIndex; this.elements = JavaElement.NO_ELEMENTS; @@ -432,9 +497,9 @@ parameterSignatures[0] = Signature.getTypeErasure(enclosingDeclaringTypeSignature); } - acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, uniqueKey, isConstructor); + acceptBinaryMethod(type, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, typeParameterNames, typeParameterBoundNames, uniqueKey, isConstructor); } else { - acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames, uniqueKey); + acceptSourceMethod(type, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, typeParameterNames, typeParameterBoundNames, uniqueKey); } } } @@ -469,7 +534,16 @@ * * fix for 1FWFT6Q */ -protected void acceptSourceMethod(IType type, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, char[] uniqueKey) { +protected void acceptSourceMethod( + IType type, + char[] selector, + char[][] parameterPackageNames, + char[][] parameterTypeNames, + String[] parameterSignatures, + char[][] typeParameterNames, + char[][][] typeParameterBoundNames, + char[] uniqueKey) { + String name = new String(selector); IMethod[] methods = null; try { @@ -478,12 +552,15 @@ if (methods[i].getElementName().equals(name) && methods[i].getParameterTypes().length == parameterTypeNames.length) { IMethod method = methods[i]; - if (uniqueKey != null) - method = new ResolvedSourceMethod( + if (uniqueKey != null) { + ResolvedSourceMethod resolvedMethod = new ResolvedSourceMethod( (JavaElement)method.getParent(), method.getElementName(), method.getParameterTypes(), new String(uniqueKey)); + resolvedMethod.occurrenceCount = method.getOccurrenceCount(); + method = resolvedMethod; + } addElement(method); } } @@ -530,6 +607,11 @@ break; } } + + if (match && !areTypeParametersCompatible(method, typeParameterNames, typeParameterBoundNames)) { + match = false; + } + if (match) { addElement(method); if(SelectionEngine.DEBUG){ @@ -666,7 +748,45 @@ } this.elements[++this.elementIndex] = element; } - +private boolean areTypeParametersCompatible(IMethod method, char[][] typeParameterNames, char[][][] typeParameterBoundNames) { + try { + ITypeParameter[] typeParameters = method.getTypeParameters(); + int length1 = typeParameters == null ? 0 : typeParameters.length; + int length2 = typeParameterNames == null ? 0 : typeParameterNames.length; + if (length1 != length2) { + return false; + } else { + for (int j = 0; j < length1; j++) { + ITypeParameter typeParameter = typeParameters[j]; + String typeParameterName = typeParameter.getElementName(); + if (!typeParameterName.equals(new String(typeParameterNames[j]))) { + return false; + } + + String[] bounds = typeParameter.getBounds(); + int boundCount = typeParameterBoundNames[j] == null ? 0 : typeParameterBoundNames[j].length; + + if (bounds.length != boundCount) { + return false; + } else { + for (int k = 0; k < boundCount; k++) { + String simpleName = Signature.getSimpleName(bounds[k]); + int index = simpleName.indexOf('<'); + if (index != -1) { + simpleName = simpleName.substring(0, index); + } + if (!simpleName.equals(new String(typeParameterBoundNames[j][k]))) { + return false; + } + } + } + } + } + } catch (JavaModelException e) { + return false; + } + return true; +} /* * findLocalElement() cannot find local variable */ 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.295 diff -u -r1.295 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 4 Dec 2006 09:06:42 -0000 1.295 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 7 Dec 2006 14:30:00 -0000 @@ -1225,7 +1225,7 @@ if (current instanceof ParameterizedMethodBinding) for (int j = i + 1; j < visiblesCount; j++) if (current.declaringClass == candidates[j].declaringClass && current.areParametersEqual(candidates[j])) - return new ProblemMethodBinding(candidates[i].selector, candidates[i].parameters, ProblemReasons.Ambiguous); + return new ProblemMethodBinding(candidates[i], candidates[i].selector, candidates[i].parameters, ProblemReasons.Ambiguous); } } @@ -3143,7 +3143,7 @@ return method; } if (problemMethod == null) - return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); + return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); return problemMethod; } @@ -3189,7 +3189,7 @@ return method; } if (problemMethod == null) - return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); + return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); return problemMethod; } @@ -3256,7 +3256,7 @@ } } } else if (count == 0) { - return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); + return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); } // found several methods that are mutually acceptable -> must be equal @@ -3394,7 +3394,7 @@ } // if all moreSpecific methods are equal then see if duplicates exist because of substitution - return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); + return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous); } public final ClassScope outerMostClassScope() { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java,v retrieving revision 1.13 diff -u -r1.13 ProblemMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java 27 Nov 2006 17:23:19 -0000 1.13 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java 7 Dec 2006 14:29:59 -0000 @@ -31,7 +31,7 @@ public ProblemMethodBinding(MethodBinding closestMatch, char[] selector, TypeBinding[] args, int problemReason) { this(selector, args, problemReason); this.closestMatch = closestMatch; - if (closestMatch != null) this.declaringClass = closestMatch.declaringClass; + if (closestMatch != null && problemReason != ProblemReasons.Ambiguous) this.declaringClass = closestMatch.declaringClass; } /* API * Answer the problem id associated with the receiver. Index: codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java,v retrieving revision 1.27 diff -u -r1.27 ISelectionRequestor.java --- codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java 28 Mar 2006 20:30:02 -0000 1.27 +++ codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java 7 Dec 2006 14:29:59 -0000 @@ -160,6 +160,8 @@ char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, + char[][] typeParameterNames, + char[][][] typeParameterBoundNames, boolean isConstructor, boolean isDeclaration, char[] uniqueKey, Index: codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java,v retrieving revision 1.133 diff -u -r1.133 SelectionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 24 Nov 2006 01:32:03 -0000 1.133 +++ codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 7 Dec 2006 14:29:59 -0000 @@ -873,6 +873,31 @@ parameterSignatures[i] = new String(getSignature(parameterTypes[i])).replace('/', '.'); } + TypeVariableBinding[] typeVariables = methodBinding.original().typeVariables; + length = typeVariables == null ? 0 : typeVariables.length; + char[][] typeParameterNames = new char[length][]; + char[][][] typeParameterBoundNames = new char[length][][]; + for (int i = 0; i < length; i++) { + TypeVariableBinding typeVariable = typeVariables[i]; + typeParameterNames[i] = typeVariable.sourceName; + if (typeVariable.firstBound == null) { + typeParameterBoundNames[i] = new char[0][]; + } else if (typeVariable.firstBound == typeVariable.superclass) { + int boundCount = 1 + (typeVariable.superInterfaces == null ? 0 : typeVariable.superInterfaces.length); + typeParameterBoundNames[i] = new char[boundCount][]; + typeParameterBoundNames[i][0] = typeVariable.superclass.sourceName; + for (int j = 1; j < boundCount; j++) { + typeParameterBoundNames[i][j] = typeVariables[i].superInterfaces[j - 1].sourceName; + } + } else { + int boundCount = typeVariable.superInterfaces == null ? 0 : typeVariable.superInterfaces.length; + typeParameterBoundNames[i] = new char[boundCount][]; + for (int j = 0; j < boundCount; j++) { + typeParameterBoundNames[i][j] = typeVariables[i].superInterfaces[j].sourceName; + } + } + } + ReferenceBinding declaringClass = methodBinding.declaringClass; if (isLocal(declaringClass) && this.requestor instanceof SelectionRequestor) { ((SelectionRequestor)this.requestor).acceptLocalMethod(methodBinding); @@ -887,6 +912,8 @@ parameterPackageNames, parameterTypeNames, parameterSignatures, + typeParameterNames, + typeParameterBoundNames, methodBinding.isConstructor(), isDeclaration, methodBinding.computeUniqueKey(), @@ -1239,6 +1266,8 @@ null, // SelectionRequestor does not need of parameters type for method declaration null, // SelectionRequestor does not need of parameters type for method declaration null, // SelectionRequestor does not need of parameters type for method declaration + null, // SelectionRequestor does not need of type parameters name for method declaration + null, // SelectionRequestor does not need of type parameters bounds for method declaration method.isConstructor(), true, method.binding != null ? method.binding.computeUniqueKey() : null, Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java,v retrieving revision 1.59 diff -u -r1.59 CodeSnippetToCuMapper.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 16 Oct 2006 17:21:09 -0000 1.59 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 7 Dec 2006 14:30:01 -0000 @@ -285,8 +285,8 @@ public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, boolean isDeclaration, char[] uniqueKey, int start, int end) { originalRequestor.acceptField(declaringTypePackageName, declaringTypeName, name, isDeclaration, uniqueKey, start, end); } - 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) { - originalRequestor.acceptMethod(declaringTypePackageName, declaringTypeName, enclosingDeclaringTypeSignature, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, isConstructor, isDeclaration, uniqueKey, start, end); + 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) { + originalRequestor.acceptMethod(declaringTypePackageName, declaringTypeName, enclosingDeclaringTypeSignature, selector, parameterPackageNames, parameterTypeNames, parameterSignatures, typeParameterNames, typeParameterBoundNames, isConstructor, isDeclaration, uniqueKey, start, end); } public void acceptPackage(char[] packageName) { originalRequestor.acceptPackage(packageName); Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java,v retrieving revision 1.44 diff -u -r1.44 CodeSnippetScope.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 20 Oct 2006 11:02:03 -0000 1.44 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 7 Dec 2006 14:30:01 -0000 @@ -312,7 +312,7 @@ if (visibleField == null) visibleField = field; else - return new ProblemFieldBinding(visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous); + return new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous); } else { notVisible = true; } @@ -334,7 +334,7 @@ if (visibleField == null) { visibleField = field; } else { - ambiguous = new ProblemFieldBinding(visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous); + ambiguous = new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous); break done; } } else { Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v retrieving revision 1.117 diff -u -r1.117 MessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 28 Oct 2006 04:11:27 -0000 1.117 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 7 Dec 2006 14:29:59 -0000 @@ -403,6 +403,7 @@ MethodBinding closestMatch = ((ProblemMethodBinding)binding).closestMatch; switch (this.binding.problemId()) { case ProblemReasons.Ambiguous : + break; // no resilience on ambiguous case ProblemReasons.NotVisible : case ProblemReasons.NonStaticReferenceInConstructorInvocation : case ProblemReasons.NonStaticReferenceInStaticContext : Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java,v retrieving revision 1.30 diff -u -r1.30 JavadocMessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 25 Nov 2006 19:49:51 -0000 1.30 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 7 Dec 2006 14:29:59 -0000 @@ -120,6 +120,7 @@ case ProblemReasons.NonStaticReferenceInConstructorInvocation: case ProblemReasons.NonStaticReferenceInStaticContext: case ProblemReasons.InheritedNameHidesEnclosingName : + case ProblemReasons.Ambiguous: MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch; if (closestMatch != null) { this.binding = closestMatch; // ignore problem if can reach target method through it @@ -135,11 +136,7 @@ return null; } } - // do not report ambiguous problems on methods as they can appears only when source level >= 1.5 and they cannot be fixed! - // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=165794 - if (this.binding.problemId() != ProblemReasons.Ambiguous) { - scope.problemReporter().javadocInvalidMethod(this, this.binding, scope.getDeclarationModifiers()); - } + scope.problemReporter().javadocInvalidMethod(this, this.binding, scope.getDeclarationModifiers()); // record the closest match, for clients who may still need hint about possible method match if (this.binding instanceof ProblemMethodBinding) { MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;