On Thu, 13 Oct 2022 21:46:15 GMT, ExE Boss <d...@openjdk.org> wrote:

>> Nope, there'd be a compilation error
>
> It'll work fine if an unchecked cast is used:
> Suggestion:
> 
>             @SuppressWarnings("unchecked")
>             Comparator<Map.Entry<K, V>> entryComparator = treeComparator == 
> null ?
>                     (Comparator) Map.Entry.comparingByKey()
>                     Map.Entry.comparingByKey(treeComparator);
>             return entryComparator;
> 
> 
> This also ensures that when `treeComparator` is `null`, this method keeps 
> returning a constant lambda.

This one looks fine, accepted.

-------------

PR: https://git.openjdk.org/jdk/pull/9901

Reply via email to