Skip to content

Commit

Permalink
Support unnamed
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Jan 12, 2024
1 parent dc0ff7a commit a95ff16
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ private VariableDeclaration convertVariableDeclaration(JCVariableDecl javac) {
// if (singleDecl) {
SingleVariableDeclaration res = this.ast.newSingleVariableDeclaration();
commonSettings(res, javac);
res.setName((SimpleName)convert(javac.getName()));
if (convert(javac.getName()) instanceof SimpleName simpleName) {
res.setName(simpleName);
}
res.modifiers().addAll(convert(javac.getModifiers()));
if (javac.getType() != null) {
res.setType(convertToType(javac.getType()));
Expand Down Expand Up @@ -958,7 +960,7 @@ private Modifier convert(javax.lang.model.element.Modifier javac) {
}

private Name convert(com.sun.tools.javac.util.Name javac) {
if (javac == null || Objects.equals(javac, Names.instance(this.context).error)) {
if (javac == null || Objects.equals(javac, Names.instance(this.context).error) || Objects.equals(javac, Names.instance(this.context).empty)) {
return null;
}
int lastDot = javac.lastIndexOf((byte)'.');
Expand Down

0 comments on commit a95ff16

Please sign in to comment.