Integrated: 8256149: Weird AST structure for incomplete member select

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


On Wed, 11 Nov 2020 09:01:52 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: d0c52651
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/d0c52651
Stats:     61 lines in 2 files changed: 60 ins; 0 del; 1 mod

8256149: Weird AST structure for incomplete member select

Reviewed-by: vromero

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

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


More information about the compiler-dev mailing list