Closed blipper closed 1 month ago
import java.util.Collections; class A { void foo( { Collections.singletonList(null); } }
class A { void foo( { List.of(null); } }
Really this should be any provably null or if conservative only provably non-null.
This is a problem because singleList allows null element. https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html#of(E) https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collections.html#singletonList(T)
The same problem applies to Map as well.
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
What did you see instead?
Really this should be any provably null or if conservative only provably non-null.
This is a problem because singleList allows null element. https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html#of(E) https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collections.html#singletonList(T)
Are you interested in contributing a fix to OpenRewrite?