Skip to content

fallbackNullableAnnotation causes double-annotations when mixed with other nullable annotation types #1614

@mmorrisontx

Description

@mmorrisontx

This input:

@org.immutables.value.Value.Immutable
public abstract class Test {
    public abstract @jakarta.annotation.Nullable String getStringJakarta();
    public abstract @org.jspecify.annotations.Nullable String getStringJspecify();
    public abstract @org.checkerframework.checker.nullness.qual.Nullable String getStringChecker();
}

results in this expected output:

import jakarta.annotation.Nullable;
...
  private final @Nullable String stringJakarta;
  private final @org.jspecify.annotations.Nullable String stringJspecify;
  private final @org.checkerframework.checker.nullness.qual.Nullable String stringChecker;

However, this input:

@org.immutables.value.Value.Immutable
@org.immutables.value.Value.Style(fallbackNullableAnnotation = org.jspecify.annotations.Nullable.class)
public abstract class Test {
    public abstract @jakarta.annotation.Nullable String getStringJakarta();
    public abstract @org.jspecify.annotations.Nullable String getStringJspecify();
    public abstract @org.checkerframework.checker.nullness.qual.Nullable String getStringChecker();
}

results in a bunch of duplicated nullable annotations where they shouldn't be:

import jakarta.annotation.Nullable;
...
  private final @Nullable @org.jspecify.annotations.Nullable String stringJakarta;
  private final @org.jspecify.annotations.Nullable String stringJspecify;
  private final @org.checkerframework.checker.nullness.qual.Nullable @org.jspecify.annotations.Nullable String stringChecker;

I would expect this part of the output to be identical to the first test case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions