From 3e0d34981a782376fbef0f686b2749531636b8c6 Mon Sep 17 00:00:00 2001 From: Brad Corso Date: Fri, 2 Aug 2024 15:25:12 -0700 Subject: [PATCH] Add more information to error message when @AggregatedDeps annotation is missing. Users should never actually hit this error but we've seen some reports where a user hit this in https://github.com/google/dagger/issues/4362, so I've added information about the failing element to help the user further narrow down the issue. RELNOTES=N/A PiperOrigin-RevId: 658923031 --- .../internal/aggregateddeps/AggregatedDepsMetadata.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/dagger/hilt/processor/internal/aggregateddeps/AggregatedDepsMetadata.java b/java/dagger/hilt/processor/internal/aggregateddeps/AggregatedDepsMetadata.java index 840ba9c00fb..0caaf7ba282 100644 --- a/java/dagger/hilt/processor/internal/aggregateddeps/AggregatedDepsMetadata.java +++ b/java/dagger/hilt/processor/internal/aggregateddeps/AggregatedDepsMetadata.java @@ -107,8 +107,11 @@ public static AggregatedDepsIr toIr(AggregatedDepsMetadata metadata) { } private static AggregatedDepsMetadata create(XTypeElement element, XProcessingEnv env) { + checkState( + element.hasAnnotation(ClassNames.AGGREGATED_DEPS), + "Missing @AggregatedDeps annotation on %s", + element.getClassName().canonicalName()); XAnnotation annotation = element.getAnnotation(ClassNames.AGGREGATED_DEPS); - return new AutoValue_AggregatedDepsMetadata( element, getTestElement(annotation.getAnnotationValue("test"), env),