Skip to content

Commit 600b4b6

Browse files
java-team-github-botGoogle Java Core Libraries
authored andcommitted
Update @AutoAnnotation documentation to say that it isn't needed in Kotlin.
RELNOTES=Update @AutoAnnotation documentation to say that it isn't needed in Kotlin. PiperOrigin-RevId: 528617920
1 parent 75ef346 commit 600b4b6

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

common/src/main/java/com/google/auto/common/Visibility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static Visibility effectiveVisibilityOfElement(Element element) {
7777
Visibility effectiveVisibility = PUBLIC;
7878
Element currentElement = element;
7979
while (currentElement != null) {
80-
// NOTE - because that requires Guava 30, which would
80+
// NOTE: We don't use Guava's Comparators.min() because that requires Guava 30, which would
8181
// make this library unusable in annotation processors using Bazel < 5.0.
8282
effectiveVisibility = Ordering.natural().min(effectiveVisibility, ofElement(currentElement));
8383
currentElement = currentElement.getEnclosingElement();

value/src/main/java/com/google/auto/value/processor/TypeVariables.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public TypeMirror visitArray(ArrayType t, Void p) {
236236
// ImmutableSet<? extends T> target = ImmutableSet.copyOf(actualParameter);
237237
// We will infer E=<? extends T> and rewrite the formal parameter type to
238238
// <? extends T>[], which we must simplify to T[].
239-
// TODO - returns null?
239+
// TODO: what if getExtendsBound() returns null?
240240
comp = MoreTypes.asWildcard(comp).getExtendsBound();
241241
}
242242
return typeUtils.getArrayType(comp);

value/userguide/howto.md

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ good to go.
292292

293293
## <a name="annotation"></a>... use AutoValue to implement an annotation type?
294294

295+
Note: If you are writing your annotation in Kotlin, you don't need to use
296+
`@AutoAnnotation`, since Kotlin allows you to instantiate annotations directly.
297+
295298
Most users should never have the need to programmatically create "fake"
296299
annotation instances. But if you do, using `@AutoValue` in the usual way will
297300
fail because the `Annotation.hashCode` specification is incompatible with
@@ -315,28 +318,6 @@ public class Names {
315318
}
316319
```
317320

318-
In Java the method will usually be static. In Kotlin, which doesn't have static
319-
methods as such, a normal function can be used:
320-
321-
```kotlin
322-
public class Names {
323-
@AutoAnnotation public fun named(value: String): Named {
324-
return AutoAnnotation_Names_named(value);
325-
}
326-
}
327-
```
328-
329-
Kotlin also allows you to instantiate annotations directly, so you may not need
330-
AutoAnnotation:
331-
332-
```kotlin
333-
public class Names {
334-
public fun named(value: String): Named {
335-
return Named(value = value)
336-
}
337-
}
338-
```
339-
340321
If your annotation has several elements, you may prefer to use `@AutoBuilder`:
341322

342323
```java

0 commit comments

Comments
 (0)