RFR: 8332725: Binding patterns with inferred type have erroneous node in the AST
Jan Lahoda
jlahoda at openjdk.org
Thu May 23 06:30:31 UTC 2024
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.
-------------
Commit messages:
- 8332725: Binding patterns with inferred type have erroneous type in the AST
Changes: https://git.openjdk.org/jdk/pull/19357/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19357&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8332725
Stats: 93 lines in 2 files changed: 93 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/19357.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19357/head:pull/19357
PR: https://git.openjdk.org/jdk/pull/19357
More information about the compiler-dev
mailing list