Skip to content

Commit

Permalink
Includes invalid annotation name in debug message with KSP.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 508473051
  • Loading branch information
wanyingd1996 authored and Dagger Team committed Feb 9, 2023
1 parent f347c8a commit 47abf56
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions java/dagger/internal/codegen/xprocessing/XAnnotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public static String toStableString(XAnnotation annotation) {
if (annotation.getType().isError()) {
return "@" + annotation.getName(); // SUPPRESS_GET_NAME_CHECK
}
// TODO(b/264089557): Non-annotation elements can be incorrectly treated as annotation in KSP,
// therefore calling getAnnotationValues() can cause confusing error.
if (getProcessingEnv(annotation).getBackend() == XProcessingEnv.Backend.KSP
&& annotation.getTypeElement().getConstructors().size() != 1) {
return String.format("@%s", getClassName(annotation).canonicalName());
}
return annotation.getAnnotationValues().isEmpty()
// If the annotation doesn't have values then skip the empty parenthesis.
? String.format("@%s", getClassName(annotation).canonicalName())
Expand Down

0 comments on commit 47abf56

Please sign in to comment.