Diamond and Generic Methods

maurizio cimadamore maurizio.cimadamore at oracle.com
Thu May 5 12:28:39 PDT 2011


On 05/05/2011 20:08, Paul Benedict wrote:
> On Thu, May 5, 2011 at 2:04 PM, Dan Smith<daniel.smith at oracle.com>  wrote:
>> Taking a stab at it, I think you're saying inference chooses 'T' as the type argument for 'new ArrayList<>' (or has "the appearance" of choosing 'T').
> I think you understand my concern for the most part. I was just
> expressing my opinion that I think most people would read this:
>
> identity(new java.util.ArrayList<>());
>
> ..as a shorthand for..
>
> identity(new java.util.ArrayList<T>());
Uhm, not sure I get what you are saying, T is not even in scope at that 
point!

Maurizio
> ... and not make the mental leap that they are really doing:
>
> identity(new java.util.ArrayList<Object>());
>
> Diamond's inference is being sold as a shortcut.. so we may find out
> it exposes mental shortcuts too :-)
>
> Paul
>




More information about the coin-dev mailing list