[PATCH] Diagnostic position fix for statement-bodied lambdas
Vicente-Arturo Romero-Zaldivar
vicente.romero at oracle.com
Mon Nov 17 19:14:06 UTC 2014
Hi Liam,
I don't know of any reason to use the position of the arguments as the
position of the lambda body. I will sponsor your patch,
Thanks,
Vicente
On 11/14/2014 05:16 PM, Liam Miller-Cushon wrote:
> When parsing statement-bodied lambda expressions, javac currently uses
> the start position of the parameter list for the body. This patch
> fixes the parser to record the body's start position correctly.
>
> Example diagnostic before this change:
>
> Test.java:17: error: incompatible types: bad return type in lambda
> expression
> foo((x) -> { return ""; System.out.println(""); });
> ^
>
> After:
>
> Test.java:17: error: lambda body is neither value nor void compatible
> foo((x) -> { return ""; System.out.println(""); });
> ^
>
> Placing the caret at the parameter list may be deliberate, but it
> should be possible to do that without recording the body's start
> position incorrectly.
>
> Thanks,
> Liam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20141117/79f5f7da/attachment.html>
More information about the compiler-dev
mailing list