diff --git a/common/src/main/java/com/google/auto/common/Visibility.java b/common/src/main/java/com/google/auto/common/Visibility.java index 266d4fdbc7..db15f8bd43 100644 --- a/common/src/main/java/com/google/auto/common/Visibility.java +++ b/common/src/main/java/com/google/auto/common/Visibility.java @@ -77,7 +77,7 @@ public static Visibility effectiveVisibilityOfElement(Element element) { Visibility effectiveVisibility = PUBLIC; Element currentElement = element; while (currentElement != null) { - // NOTE - because that requires Guava 30, which would + // NOTE: We don't use Guava's Comparators.min() because that requires Guava 30, which would // make this library unusable in annotation processors using Bazel < 5.0. effectiveVisibility = Ordering.natural().min(effectiveVisibility, ofElement(currentElement)); currentElement = currentElement.getEnclosingElement(); diff --git a/value/src/main/java/com/google/auto/value/processor/TypeVariables.java b/value/src/main/java/com/google/auto/value/processor/TypeVariables.java index 5000389ee3..ae27f91b46 100644 --- a/value/src/main/java/com/google/auto/value/processor/TypeVariables.java +++ b/value/src/main/java/com/google/auto/value/processor/TypeVariables.java @@ -236,7 +236,7 @@ public TypeMirror visitArray(ArrayType t, Void p) { // ImmutableSet target = ImmutableSet.copyOf(actualParameter); // We will infer E= and rewrite the formal parameter type to // [], which we must simplify to T[]. - // TODO - returns null? + // TODO: what if getExtendsBound() returns null? comp = MoreTypes.asWildcard(comp).getExtendsBound(); } return typeUtils.getArrayType(comp); diff --git a/value/userguide/howto.md b/value/userguide/howto.md index e48572dadf..5acbd024a7 100644 --- a/value/userguide/howto.md +++ b/value/userguide/howto.md @@ -292,6 +292,9 @@ good to go. ## ... use AutoValue to implement an annotation type? +Note: If you are writing your annotation in Kotlin, you don't need to use +`@AutoAnnotation`, since Kotlin allows you to instantiate annotations directly. + Most users should never have the need to programmatically create "fake" annotation instances. But if you do, using `@AutoValue` in the usual way will fail because the `Annotation.hashCode` specification is incompatible with @@ -315,28 +318,6 @@ public class Names { } ``` -In Java the method will usually be static. In Kotlin, which doesn't have static -methods as such, a normal function can be used: - -```kotlin -public class Names { - @AutoAnnotation public fun named(value: String): Named { - return AutoAnnotation_Names_named(value); - } -} -``` - -Kotlin also allows you to instantiate annotations directly, so you may not need -AutoAnnotation: - -```kotlin -public class Names { - public fun named(value: String): Named { - return Named(value = value) - } -} -``` - If your annotation has several elements, you may prefer to use `@AutoBuilder`: ```java