Skip to content

Formatter produces inconsistent result with nullable annotations in certain positions #435

Closed

Description

@shakuzen

The formatting applied is different depending on whether a type annotation is applied to an array type or a varargs type. See the following examples:

  • With an Array type there is a space between the type annotation (@Nullable) and the type ([])
private static boolean isEmptyVarargs(@Nullable Object @Nullable [] args) {
  • With Varargs there is no space between the type annotation (@Nullable) and the type (...)
public KeyValues and(String @Nullable... keyValues) {

Activity

  1. changed the title [-]Inconsistent formatting with type annotations on array vs varargs[/-] [+]Inconsistent formatting with nullable annotations[/+] on May 3, 2025
  2. philwebb commented on May 3, 2025

    @philwebb
    Contributor

    Expanding the scope of this one because @snicoll also discovered:

    public @Nullable Object publicThing();
    
    @Nullable Object packagePrivateThing();

    results in:

    public @Nullable Object publicThing();
    
    @Nullable
    Object packagePrivateThing();
  3. changed the title [-]Inconsistent formatting with nullable annotations[/-] [+]Formatter produces inconsistent result with nullable annotations in certain positions[/+] on May 3, 2025
  4. added this to the 0.0.44 milestone on May 3, 2025
  5. self-assigned this
    on May 3, 2025
  6. added a commit that references this issue on Jul 8, 2025
    355abdc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions