Skip to content

JSpecifyExperimental: false positive for addAll with ? element type #1822

Description

@unv-unv

JSpecifyExperimental mode on.

@NullMarked
class Test {
    public Collection<Object> foo(List<?> list) {
        List<Object> result = new ArrayList<>();
        // BUG: List<?> cannot be converted to Collection<? extends Object> (List<?> is a subtype of Collection<?>)
        result.addAll(list);
        return result;
    }
}

Shows compilation error:

[ERROR]Test.java[6,22]: [NullAway] incompatible types: List<?> cannot be converted to Collection<? extends Object> (List<?> is a subtype of Collection<?>)

NullAway 0.14.1, Error Prone 2.50.0.

Activity

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

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