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

(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (+40 lines)
Lines 5031-5034 Link Here
5031
			);
5031
			);
5032
		}
5032
		}
5033
	}
5033
	}
5034
5035
	/**
5036
	 * @bug 165794: [javadoc] Should not report ambiguous on method with parameterized types as parameters
5037
	 * @test Ensure that no warning are raised when ambiguous parameterized methods are present in javadoc comments
5038
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=165794"
5039
	 */
5040
	public void testBug165794() {
5041
		String[] testFiles = new String[] {
5042
			"X.java",
5043
			"/**\n" + 
5044
			" * No reasonable hint for resolving the {@link #getMax(A)}.\n" + 
5045
			" */\n" + 
5046
			"public class X {\n" + 
5047
			"    /**\n" + 
5048
			"     * Extends Number method.\n" + 
5049
			"     * @see #getMax(A ipZ)\n" + 
5050
			"     */\n" + 
5051
			"    public <T extends Y> T getMax(final A<T> ipY) {\n" + 
5052
			"        return ipY.t();\n" + 
5053
			"    }\n" + 
5054
			"    \n" + 
5055
			"    /**\n" + 
5056
			"     * Extends Exception method.\n" + 
5057
			"     * @see #getMax(A ipY)\n" + 
5058
			"     */\n" + 
5059
			"    public <T extends Z> T getMax(final A<T> ipZ) {\n" + 
5060
			"        return ipZ.t();\n" + 
5061
			"    }\n" + 
5062
			"}\n" + 
5063
			"class A<T> {\n" + 
5064
			"	T t() { return null; }\n" + 
5065
			"}\n" + 
5066
			"class Y {}\n" + 
5067
			"class Z {}"
5068
		};
5069
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5070
			return;
5071
		}
5072
		runConformTest(testFiles);
5073
	}
5034
}
5074
}
(-)src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java (+66 lines)
Lines 919-922 Link Here
919
			elements
919
			elements
920
		);
920
		);
921
	}
921
	}
922
923
	/**
924
	 * @bug 165701: [model] No hint for ambiguous javadoc
925
	 * @test Ensure that no exception is thrown while selecting method in javadoc comment
926
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=165701"
927
	 */
928
	public void testBug165701() throws JavaModelException {
929
		setUnit("b165701/Test.java",
930
			"package b165701;\n" + 
931
			"/**\n" + 
932
			" * @see #fooo(int)\n" + 
933
			" */\n" + 
934
			"public class Test {\n" + 
935
			"	public void foo() {}\n" + 
936
			"}\n"
937
		);
938
		int[] selectionPositions = selectionInfo(workingCopies[0], "fooo", 1);
939
		IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0);
940
		assertElementsEqual("Invalid selection(s)",
941
			"Test [in [Working copy] Test.java [in b165701 [in <project root> [in Tests]]]]",
942
			elements
943
		);
944
	}
945
946
	/**
947
	 * @bug 165794: [model] No hint for ambiguous javadoc
948
	 * @test Ensure that no exception is thrown while selecting method in javadoc comment
949
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=165794"
950
	 */
951
	public void testBug165794() throws JavaModelException {
952
		setUnit("b165794/Test.java",
953
			"package b165794;\n" + 
954
			"/**\n" + 
955
			" * No reasonable hint for resolving the {@link #getMax(A)}.\n" + 
956
			" */\n" + 
957
			"public class X {\n" + 
958
			"    /**\n" + 
959
			"     * Extends Number method.\n" + 
960
			"     * @see #getMax(A ipZ)\n" + 
961
			"     */\n" + 
962
			"    public <T extends Y> T getMax(final A<T> ipY) {\n" + 
963
			"        return ipY.t();\n" + 
964
			"    }\n" + 
965
			"    \n" + 
966
			"    /**\n" + 
967
			"     * Extends Exception method.\n" + 
968
			"     * @see #getMax(A ipY)\n" + 
969
			"     */\n" + 
970
			"    public <T extends Z> T getMax(final A<T> ipZ) {\n" + 
971
			"        return ipZ.t();\n" + 
972
			"    }\n" + 
973
			"}\n" + 
974
			"class A<T> {\n" + 
975
			"	T t() { return null; }\n" + 
976
			"}\n" + 
977
			"class Y {}\n" + 
978
			"class Z {}"
979
		);
980
		int[] selectionPositions = selectionInfo(workingCopies[0], "getMax", 1);
981
		IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0);
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]]]]]",
985
			elements
986
		);
987
	}
922
}
988
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java (-2 / +4 lines)
Lines 135-143 Link Here
135
					return null;
135
					return null;
136
				}
136
				}
137
			}
137
			}
138
			scope.problemReporter().javadocInvalidMethod(this, this.binding, scope.getDeclarationModifiers());
138
			if (this.binding.problemId() != ProblemReasons.Ambiguous) {
139
				scope.problemReporter().javadocInvalidMethod(this, this.binding, scope.getDeclarationModifiers());
140
			}
139
			// record the closest match, for clients who may still need hint about possible method match
141
			// record the closest match, for clients who may still need hint about possible method match
140
			if (this.binding instanceof ProblemMethodBinding){
142
			if (this.binding instanceof ProblemMethodBinding) {
141
				MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
143
				MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
142
				if (closestMatch != null) this.binding = closestMatch;
144
				if (closestMatch != null) this.binding = closestMatch;
143
			}
145
			}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-1 / +2 lines)
Lines 3388-3394 Link Here
3388
		}
3388
		}
3389
3389
3390
		// if all moreSpecific methods are equal then see if duplicates exist because of substitution
3390
		// if all moreSpecific methods are equal then see if duplicates exist because of substitution
3391
		return new ProblemMethodBinding(visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3391
		return new ProblemMethodBinding(visible[0], visible[0].selector, visible[0].parameters, ProblemReasons.Ambiguous);
3392
3392
	}
3393
	}
3393
3394
3394
	public final ClassScope outerMostClassScope() {
3395
	public final ClassScope outerMostClassScope() {

Return to bug 165794