RFR: 8253584: Redunant errors for partial member selects [v2]
Jan Lahoda
jlahoda at openjdk.java.net
Tue Sep 29 06:52:22 UTC 2020
> For code like:
> package t;
>
> class Test {
>
> void t() {
> if (true) {
> s().
> } else {
> }
> }
>
> String s() {
> return null;
> }
> }
>
> (note the missing member name after `s().`), javac will produce a number of compile-time errors:
> $ javac /tmp/Test.java
>
> s().
> ^
>
> s().
> ^
>
> } else {
> ^
>
> } else {
> ^
>
> String s() {
> ^
>
> }
> ^
> 6 errors
>
> The reason is that after not seeing an identifier after the `.` javac will skip the token that follows the dot. This
> was done to improve errors in https://bugs.openjdk.java.net/browse/JDK-8081769 . But here, reading the next token will
> skip the closing `}`, and the parser will de-synchronize with the braces, leading to the follow-up errors. The
> proposal here is to handle incorrect `.class` specially, and avoid reading the next token when an identifier is no
> specified in a member select, except when the next token is `class`. The errors with this patch are:
> $ javac /tmp/Test.java
>
> s().
> ^
>
> s().
> ^
> 2 errors
>
> This seems much better.
Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev
excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since
the last revision:
- Merge branch 'master' into JDK-8253584
- 8253584: Redunant errors for partial member selects
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/333/files
- new: https://git.openjdk.java.net/jdk/pull/333/files/914c9fde..9bc235ad
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=333&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=333&range=00-01
Stats: 28156 lines in 596 files changed: 4818 ins; 21874 del; 1464 mod
Patch: https://git.openjdk.java.net/jdk/pull/333.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/333/head:pull/333
PR: https://git.openjdk.java.net/jdk/pull/333
More information about the compiler-dev
mailing list