Skip to content

Commit

Permalink
Improve the error message for conflicting entry points.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 446074483
  • Loading branch information
Chang-Eric authored and Dagger Team committed May 3, 2022
1 parent 0dfbcaa commit dfab36d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class DiagnosticFormatting {
* parameterized) type, and should NOT be used with arbitrary text, especially prose error
* messages.
*
* <p>TODO(user): Tighten these to take type representations (mirrors and elements) to avoid
* <p>TODO(cgruber): Tighten these to take type representations (mirrors and elements) to avoid
* accidental mis-use by running errors through this method.
*/
public static String stripCommonTypePrefixes(String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@ private void reportConflictingEntryPoints(Collection<XMethodElement> methods) {
== methods.size(),
"expected each method to be declared on a different type: %s",
methods);
StringBuilder message = new StringBuilder("conflicting entry point declarations:");
StringBuilder message = new StringBuilder("Found conflicting entry point declarations. "
+ "Getter methods on the component with the same name and signature must be for the "
+ "same binding key since the generated component can only implement the method once. "
+ "Found:");
methodSignatureFormatter
.typedFormatter(component.getType())
.formatIndentedList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void covariantType() {
assertThat(compilation)
.hadErrorContaining(
message(
"conflicting entry point declarations:",
"can only implement the method once. Found:",
" Long test.Base1.foo()",
" Number test.Base2.foo()"))
.inFile(component)
Expand Down Expand Up @@ -119,7 +119,7 @@ public void covariantTypeFromGenericSupertypes() {
assertThat(compilation)
.hadErrorContaining(
message(
"conflicting entry point declarations:",
"can only implement the method once. Found:",
" Long test.Base1.foo()",
" Number test.Base2.foo()"))
.inFile(component)
Expand Down Expand Up @@ -170,7 +170,7 @@ public void differentQualifier() {
assertThat(compilation)
.hadErrorContaining(
message(
"conflicting entry point declarations:",
"can only implement the method once. Found:",
" Object test.Base1.foo()",
" @Named(\"foo\") Object test.Base2.foo()"))
.inFile(component)
Expand Down
2 changes: 1 addition & 1 deletion javatests/dagger/internal/codegen/KeyFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static final class BoxedPrimitiveTypes {
processingEnv.requireTypeElement(BoxedPrimitiveTypes.class.getCanonicalName());
XMethodElement integerMethod = getOnlyElement(boxedPrimitiveHolder.getDeclaredMethods());

// TODO(user): Truth subject for TypeMirror and TypeElement
// TODO(cgruber): Truth subject for TypeMirror and TypeElement
XType intType = intMethod.getReturnType();
assertThat(isPrimitive(intType)).isTrue();
XType integerType = integerMethod.getReturnType();
Expand Down

0 comments on commit dfab36d

Please sign in to comment.