Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shakuzen opened this issue Apr 23, 2025 · 1 comment
Assignees
Milestone

Comments

@shakuzen
Copy link

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) {
@philwebb philwebb changed the title Inconsistent formatting with type annotations on array vs varargs Inconsistent formatting with nullable annotations May 3, 2025
@philwebb
Copy link
Contributor

philwebb commented May 3, 2025

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();

@philwebb philwebb changed the title Inconsistent formatting with nullable annotations Formatter produces inconsistent result with nullable annotations in certain positions May 3, 2025
@philwebb philwebb added this to the 0.0.44 milestone May 3, 2025
@philwebb philwebb self-assigned this May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants