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

Jan Lahoda jan.lahoda at oracle.com
Thu May 16 09:38:27 UTC 2019


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:

JBS: https://bugs.openjdk.java.net/browse/JDK-8224031

How does this look?


More information about the compiler-dev mailing list