RFR: 8332725: Binding patterns with inferred type have erroneous node in the AST
Adam Sotona
asotona at openjdk.org
Tue May 28 12:27:04 UTC 2024
On Thu, 23 May 2024 06:25:19 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> For local variable type inference, javac will set a synthetic type tree/AST for the variable. I.e. having `var v = 0;`, javac will set synthetic `int` to `JCVariableDecl.vartype`.
>
> For binding patterns, this is not done. I.e. having `R(var v)`, the `vartype` in the `JCVariableDecl` inside the binding pattern will not be set. If `Attr.preFlow` or `Attr.postAttr` is called, the missing `vartype` will be set of an erroneous tree node, despite the original code being valid.
>
> The proposal in this PR is to simply set the synthetic type tree, as is done for other cases where `var` is used.
Looks good to me.
-------------
Marked as reviewed by asotona (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/19357#pullrequestreview-2082639219
More information about the compiler-dev
mailing list