diff options
author | Éamonn McManus <emcmanus@google.com> | 2021-03-24 10:29:06 -0700 |
---|---|---|
committer | Google Java Core Libraries <java-libraries-firehose+copybara@google.com> | 2021-03-24 10:30:11 -0700 |
commit | 0b4fd6a4e9e3a72460ca7db34d94d4c6c2bd9005 (patch) | |
tree | 3d080117f0e49e8a474651105f036e5b57cd6dc5 /value/src/test/java/com/google | |
parent | 4d01ce625157105f24c0526bc210f40ae72b81ed (diff) | |
download | auto-0b4fd6a4e9e3a72460ca7db34d94d4c6c2bd9005.tar.gz |
Directly return an `AnnotationMirror` for `@Nullable`, rather than a `DeclaredType`.
The old logic was unnecessarily tortuous, extracting the `DeclaredType` for the `@Nullable` annotation we found, then later synthesizing a new `AnnotationMirror` for that type. We can just use the original `AnnotationMirror`.
Later we will probably introduce logic to use the [JSpecify](http://jspecify.org) `@Nullable` if it is available and if the `@AutoValue` class doesn't mention its own `@Nullable`. At that point we can go back to synthesizing an `AnnotationMirror`, but only for that particular case.
RELNOTES=n/a
PiperOrigin-RevId: 364834935
Diffstat (limited to 'value/src/test/java/com/google')
-rw-r--r-- | value/src/test/java/com/google/auto/value/processor/NullablesTest.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/value/src/test/java/com/google/auto/value/processor/NullablesTest.java b/value/src/test/java/com/google/auto/value/processor/NullablesTest.java index 1648bd1f..9e345f53 100644 --- a/value/src/test/java/com/google/auto/value/processor/NullablesTest.java +++ b/value/src/test/java/com/google/auto/value/processor/NullablesTest.java @@ -39,6 +39,7 @@ import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; @@ -165,7 +166,9 @@ public class NullablesTest { expect .withMessage("method %s should have @Nullable", nullableMethod) .about(optionals()) - .that(Nullables.nullableMentionedInMethods(notNullablePlusNullable)) + .that( + Nullables.nullableMentionedInMethods(notNullablePlusNullable) + .map(AnnotationMirror::getAnnotationType)) .hasValue(nullableType); } ran = true; |