Skip to content

with methods do not handle fallbackNullableAnnotation properly on Map types #1580

@mmorrisontx

Description

@mmorrisontx

Example input code:

import java.util.List;
import java.util.Map;
import org.immutables.value.Value;
import org.jspecify.annotations.Nullable;

@Value.Immutable
@Value.Style(fallbackNullableAnnotation = Nullable.class)
public abstract class Test {
    public abstract @Nullable List<String> getList();
    public abstract @Nullable Map<String, String> getMap();
}

This results in correct signatures of withList:

public final ImmutableTest withList(String @Nullable ... elements) {
public final ImmutableTest withList(@Nullable Iterable<String> elements) {

but an incorrect signature of withMap (missing @Nullable):

public final ImmutableTest withMap(Map<String, ? extends String> entries) {

The null check still exists within the method, only the parameter is missing its annotation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions