overload resolution with deep nested lambda
anna.kozlova at jetbrains.com
anna.kozlova at jetbrains.com
Thu Sep 11 14:26:58 UTC 2014
the part "A method is applicable if it is either applicable by
subtyping (§15.12.2.2), applicable by method invocation conversion
(§15.12.2.3), or it is an applicable variable arity method
(§15.12.2.4)." is from JLS 7, JLS 8 doesn't say so anymore.
I believe that (String s) -> identity(s) is not pertinent to
applicability because it is passed to the parameter with type T
(15.12.2.2) so it should not participate in invocation applicability
inference (18.5.1).
Thank you
Anna
On 11.09.2014 17:56, Davin McCall wrote:
> On 10/09/14 19:26, anna.kozlova at jetbrains.com wrote:
>>
>> Because of((String s) -> identity(s)) is potentially compatible with
>> both methods (15.12.2.1), method applicability search yields 2 methods
>> applicable by strict invocation, of which asList(Optional a) is more
>> specific (according to 18.5.4) but javac obviously chooses asList(T).
>>
>> Could someone explain what have I missed here please?
>
> I'm no expert here, but I believe that 15.12.2.1 identifies
> _potentially) applicable methods, which are then filtered according
> to
> 15.12.2.2, 15.12.2.3 and 15.12.2.4.
>
> From 15.12.2: "A method is applicable if it is either applicable by
> subtyping (§15.12.2.2), applicable by method invocation conversion
> (§15.12.2.3), or it is an applicable variable arity method
> (§15.12.2.4)."
>
> This removes the possibility of using asList(Optional), because no
> suitable type can be inferred for O. The only remaining option is
> asList(T).
>
> Davin
>
>
>
> !DSPAM:35,5411aafa47141724266025!
More information about the lambda-dev
mailing list