Notes on implementing concise calls to constructors with type parameters

Neal Gafter neal at gafter.com
Fri May 15 06:33:06 PDT 2009


On Fri, May 15, 2009 at 12:26 AM, Howard Lovatt <howard.lovatt at iee.org>wrote:

>  Consider a simple method declaration:
>
> returnType methodName ( typeLHS [<genericParametersLHS>] name , ... ) { ...
> }
>
> and a simple method call
>
> ... methodName ( new [typeRHS] [<genericParametersRHS>] ( ... ) , ... );
>
> Then the same substituting of missing items algorithm given above can
> be used. The two examples that yourself and Maurizio have discussed
> would work, i.e.:
>
> *class X<T> {*
> *  public X( T t ) { ... }*
> *}*
>
> *void f( X<String> xs ) ...*
>
> the code
>
> *f( new X( "foo" ) )*
>
> gets translated into:
>
> *f( new X<String>( "foo" ) )*
>
> and:
>
> *void f( List<String> xs ) ...*
>
> the following method call
>
> *f( new ArrayList() )*
>
> gets translated into:
>
> *f( new ArrayList<String>() )*
>
> Therefore the textual substitution method proposed works for both of
> these cases.


Is this textual substitution supposed to be applied before overload
resolution (i.e. before the method to be invoked is identified) or after
method resolution (i.e. after the types of the arguments have already been
resolved)?   Or are you planning a major overhaul of the specification of
method invocation expressions?  You haven't provided enough of a hint for us
to evaluate your proposal.  Can you please be more precise about what JLS
changes you are proposing?



More information about the coin-dev mailing list