Print `var` from its token, now that JDK 27 gives it a type node · openjavaformat/open-java-format@9c315d6 · GitHub
Skip to content

Commit 9c315d6

Browse files
committed
Print var from its token, now that JDK 27 gives it a type node
JDK 27 (JDK-8268850) gives a variable declared with `var` a VarTypeTree as its type, where earlier JDKs have none. This visitor compiles against JDK 21 and has no visitVarType, so it scanned the new node to nothing and every `var` declaration failed on JDK 27: six golden files in CI, among them FlexibleConstructor, I959 and B380299722. declareOne now looks for the `var` token before the type node, the same reordering google-java-format made in google/google-java-format@075e025c94. A binding pattern such as `Nested(var i)` has a method of its own, which now treats a VAR_TYPE node like the missing type of the older JDKs.
1 parent 97358ba commit 9c315d6

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java‎

Lines changed: 5 additions & 3 deletions

‎open-java-format/src/main/java/com/palantir/javaformat/java/java14/Java14InputAstVisitor.java‎

Lines changed: 9 additions & 1 deletion

0 commit comments

Comments
 (0)