Exceptions and lambda.
daniel.smith at oracle.com
Wed Feb 6 13:24:41 PST 2013
On Feb 6, 2013, at 6:33 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> On 06/02/13 13:03, Maurizio Cimadamore wrote:
>> On 06/02/13 12:51, Srikanth S Adayapalam wrote:
>>> I couldn't find some text that explicitly
>>> forbids the scenario we are talking about (where types are elided and inferred and
>>> there is no further need to refer to any type variables)
>> I think I cannot find it either - I think it should be in 15.27.3 Type of a Lambda Expression' - Dan?
> The only bit about this that I could find is the discussion section in 9.8 (bullet 4).
> It would seem that the text is implying that the restriction comes from the fact that a lambda has no syntax for declaring type-parameters. On the other hand I'm not sure that's enough, as the compiler could simply generate a signature that matches the one in the functional descriptor so that overriding is preserved (esp. when lambda formals are omitted).
You're right. I expect a rule in 15.27.3 that says the type parameters of the lambda (constrained to be none by the syntax) are the same as the type parameters of the function descriptor. But it seems I left out that rule.
I think the EG agreed on the behavior I describe back in April. But by "agreed," I mostly mean a silent consensus, and it's possible subtleties like this weren't fully considered. I'll write up the alternative behavior (the lambda's type params being derived from the descriptor and unmentionable) and see if it piques anyone's interest.
More information about the lambda-spec-experts