Skip to content
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

LinkedHashSet<E> should allow nullable elements #1125

Open
sdeleuze opened this issue Jan 13, 2025 · 1 comment
Open

LinkedHashSet<E> should allow nullable elements #1125

sdeleuze opened this issue Jan 13, 2025 · 1 comment

Comments

@sdeleuze
Copy link

In Spring Framework codebase with JSpecify mode enabled, when specifying

Set<@Nullable String> result = CollectionUtils.newLinkedHashSet(patterns.length);

I get

 error: [NullAway] Cannot assign from type LinkedHashSet<String> to type Set<@Nullable String> due to mismatched nullability of type parameters

If I try

Set<@Nullable String> result = CollectionUtils.<@Nullable String>newLinkedHashSet(patterns.length);

I get

error: [NullAway] Type argument cannot be @Nullable, as method <E>newLinkedHashSet(int)'s type variable E is not @Nullable

LinkedHashSet Javadoc specifies "it permits null elements" so I think this is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@sdeleuze and others