RFR: 8337976: Insufficient error recovery in parser for switch inside class body [v2]

Jan Lahoda jlahoda at openjdk.org
Mon Aug 12 12:06:16 UTC 2024


On Fri, 9 Aug 2024 17:25:48 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Adding a comment for the isDefiniteStatementStartToken.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 4923:
> 
>> 4921:     private boolean isDefiniteStatementStartToken() {
>> 4922:         return switch (token.kind) {
>> 4923:             case IF, WHILE, DO, SWITCH, RETURN, TRY, FOR, ASSERT, BREAK,
> 
> should `yield`, `synchronized` be included?

`synchronized` may be part of an method declaration (`synchronized void t() {}`). For `yield`, even though `yield` cannot be used as a type name, I thought it would be better to let the rest of error recovery mechanisms to handle it, hopefully producing some sensible error in more cases.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20526#discussion_r1713629168


More information about the compiler-dev mailing list