On Tue, 24 Jan 2023 10:23:14 GMT, Viktor Klang <d...@openjdk.org> wrote:
>> src/java.base/share/classes/java/util/ImmutableCollections.java line 169: >> >>> 167: @SuppressWarnings("unchecked") >>> 168: static <E> List<E> listCopy(Collection<? extends E> coll) { >>> 169: if (coll instanceof List12 || (coll instanceof ListN && ! >>> ((ListN<?>)coll).allowNulls)) { >> >> Maybe replace the cast with an instanceof pattern here? > > @stuart-marks Sorry, missed this notification. I initially had the same idea, > but decided against it because it forces me to suppress "rawtypes" since > `coll instanceof ListN` is not considered to be a rawtype, but `coll > instanceof ListN c` is. And currently it won't allow for `coll instanceof > ListN<E> c`... `coll instanceof ListN<?> list` should work. ------------- PR: https://git.openjdk.org/jdk/pull/11847