Skip to content

AutoBuilder with a generic parameter should be parametric in underlying type's nullability #1931

Description

@kennknowles

Consider this use of AutoBuilder:

@AutoBuilder(callMethod = "of")
public abstract static class Builder<T> {

  @Override
  public abstract Builder<T> setValue(T value);

  ...
} 

(distilled from apache/beam#34902 but I will likely have changed it with a workaround by the time you click)

The type parameter T can legitimately be instantiated with any nullability: @NonNull String, @Nullable String, etc. But the generated builder class throws NullPointerException in response to setValue(null). Instead, the builder class should be fully agnostic as to the nullability (or other qualifiers) for type T.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions