Skip to content

Fix type-use annotation duplication on nested classes and arrays - #2115

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_960390407
Aug 11, 2026
Merged

Fix type-use annotation duplication on nested classes and arrays#2115
copybara-service[bot] merged 1 commit into
mainfrom
test_960390407

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Fix type-use annotation duplication on nested classes and arrays

Type-use annotations placed at the beginning of a return type (e.g. @Nullable Enclosing.Inner or @Nullable byte[]) are associated with the left-most
type—the enclosing class type and array component type, respectively.

AutoValue's getReturnTypeAnnotations previously only checked annotations on the
root return type (e.g. Inner or byte[]), failing to check annotations on
the left-most type as return type. As a result, it treated them as method
declaration annotations and duplicated them onto the generated method.

This fix updates getReturnTypeAnnotations to inspect the left-most type
(unwrapping enclosing declared types and array component types) so type
annotations are correctly excluded from being copied to method declarations.

RELNOTES=n/a

Type-use annotations placed at the beginning of a return type (e.g. `@Nullable
Enclosing.Inner` or `@Nullable byte[]`) are associated with the left-most
type—the enclosing class type and array component type, respectively.

AutoValue's getReturnTypeAnnotations previously only checked annotations on the
root return type (e.g. `Inner` or `byte[]`), failing to check annotations on
the left-most type as return type. As a result, it treated them as method
declaration annotations and duplicated them onto the generated method.

This fix updates getReturnTypeAnnotations to inspect the left-most type
(unwrapping enclosing declared types and array component types) so type
annotations are correctly excluded from being copied to method declarations.

RELNOTES=n/a
PiperOrigin-RevId: 963017165
@copybara-service copybara-service Bot closed this Aug 11, 2026
@copybara-service
copybara-service Bot merged commit 9d4c23a into main Aug 11, 2026
@copybara-service
copybara-service Bot deleted the test_960390407 branch August 11, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant