RFR: JDK-8224031: Cannot parse switch expressions after type cast

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu May 16 10:44:25 UTC 2019


Looks good

Maurizio

On 16/05/2019 10:38, Jan Lahoda wrote:
> Hi,
>
> JavacParser.analyzeParens is used to categorize parentheses to be 
> either cast, parenthesized expression or lambda parameters. It needs 
> to be updated to categorize parentheses followed by switch as a cast:
> ---
> public class SE {
>      private void t(Integer i) {
>          String s = (String) switch (i) { default -> null; };
>      }
> }
> ---
>
> (Currently, it categorizes the above "(String)" as a parenthesized 
> expression and then fails to parse the rest of the expression.)
>
> Proposed patch:
> http://cr.openjdk.java.net/~jlahoda/8224031/webrev.00/
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8224031
>
> How does this look?
>
> Thanks,
>     Jan


More information about the compiler-dev mailing list