Stream.flatMap reference ambiguity

Dan Smith daniel.smith at oracle.com
Wed Mar 6 09:15:04 PST 2013


On Mar 4, 2013, at 10:01 AM, Zhong Yu <zhong.j.yu at gmail.com> wrote:

> 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.

Same parameters, different returns is a _prerequisite_ to being able to disambiguate.  It doesn't mean it always will.

You're right that this example will probably be ambiguous anyway.  (The interaction with inference hasn't been specified yet, but it ought to behave similarly to "foo(T)" vs. "foo(B<T>)".)

—Dan


More information about the lambda-dev mailing list