Stream.flatMap reference ambiguity

Zhong Yu zhong.j.yu at gmail.com
Mon Mar 4 09:01:30 PST 2013


On Wed, Feb 27, 2013 at 1:11 PM, Dan Smith <daniel.smith at oracle.com> wrote:
> On Feb 26, 2013, at 5:42 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:
>
>> What I'm confused about is that the sentence sounds like it's ok to
>> overload with functional interfaces that have _same_ parameter types.
>> Or is that just outright nonsense? So did you simply mean "no overload
>> with functional interfaces of the same arity"?
>
> Same parameter types, different returns.  See, for example, Stream.map.  The

Hi Dan, what exactly makes the return types "different"? For example

    <T> void foo( A->T );
    <T> void foo( A->B<T> );

is pretty ambiguous, though they have apparent different return types.

-Zhong Yu

> overload resolution logic is able to disambiguate based on what gets returned.  (That's a much easier problem that trying to choose the best types for lambda parameters based on an arbitrary block of code.)
>
> —Dan


More information about the lambda-dev mailing list