RFR: 8256149: Weird AST structure for incomplete member select [v2]

Jan Lahoda jlahoda at openjdk.java.net
Tue Dec 8 13:12:21 UTC 2020


> Consider code like:
> int i1 = "".
> @Deprecated
> void t1() {}
> 
> In current master, this will produce a somewhat twisted AST, and compile-time errors like:
> E.java:2: error: <identifier> expected
> int i = "".
>            ^
> E.java:3: error: illegal start of expression
> @Deprecated void t() {}
> ^
> E.java:3: error: ';' expected
> @Deprecated void t() {}
>            ^
> 3 errors
> 
> The reason is that `@Deprecated` is parsed as a type annotation following `"".<missing>`, which does not make much sense.
> 
> With this proposed patch, the AST is effectively the same as AST for:
> int i1 = "".; //note the semicolon here
> @Deprecated
> void t1() {}
> 
> And the errors are much better as well:
> E.java:2: error: <identifier> expected
> int i = "".
>            ^
> 1 error

Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:

 - Merging master into JDK-8256149
 - 8256149: Weird AST structure for incomplete member select

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

Changes: https://git.openjdk.java.net/jdk/pull/1159/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1159&range=01
  Stats: 61 lines in 2 files changed: 60 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1159.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1159/head:pull/1159

PR: https://git.openjdk.java.net/jdk/pull/1159


More information about the compiler-dev mailing list