overload resolution with deep nested lambda
Davin McCall
davmac at bluej.org
Thu Sep 11 13:56:55 UTC 2014
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
More information about the lambda-dev
mailing list