Issue with Comparator.comparing

B. Blaser bsrbnd at gmail.com
Thu Dec 13 13:52:06 UTC 2018


On Thu, 13 Dec 2018 at 13:30, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
>
> [...]
>
> Concluding, I really believe that the capture conversion introduced by
> JDK-8029307, which was kind of a forced move (to type check a method
> reference you have to reason about membership, which implies capture of
> the receiver), is messing things up here, because, from a type system
> perspective, it makes it look as if all possible calls to the functional
> interface derived from that method reference is _always_ going to yield
> the _same_ captured type, where in reality different captures will be
> emitted. This is what made me think that this is indeed a type system
> issue, very close (if not the same) to the one described in JDK-8170887.

At my mind, the problem is more within 'Comparator::comparing' which
assumes that the key extractor is the same for both elements
concluding that 'compareTo' should be applicable.
So, I think It might be more an API design concern than a type system
issue, but I understand your position.

Bernard

> Maurizio


More information about the compiler-dev mailing list