RFR: JDK-8192963/JDK-8206986 JEP 325: Switch Expressions (Preview)

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Aug 28 13:05:57 UTC 2018

On 28/08/18 13:41, Jan Lahoda wrote:
> It would be nicer if the second error didn't occur, but not sure how 
> to do that. It would be easy to change the classification in this case 
> to lambda, the error would then be:
> ---
> SwitchArrowBrokenConstant.java:13: error: : or -> expected
>             case (a, b) -> {}
>                              ^
> ---
> (Only this single error.) But it seems it might suggest it is OK to 
> continue from here with ':' or '->', while it is not OK. So I incline 
> more to the variant which starts with "')' expected", even if there's 
> a second error that's not very nice. 
If classification is changed to lambda, then can't we add some check in 
the lambda parsing code so that if the 'lambda allowed' mode is not set, 
an error of the kind:

'lambda not expected here'

is generated?


More information about the compiler-dev mailing list