Skip to content

Commit 33d7112

Browse files
cushonronshapiro
authored andcommitted
Don't crash on type-annotated varargs
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=156078641
1 parent aca5a77 commit 33d7112

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,13 +2320,6 @@ private void visitToDeclare(
23202320
boolean varargs = VarArgsOrNot.fromVariable(node).isYes();
23212321
List<? extends AnnotationTree> varargsAnnotations = ImmutableList.of();
23222322
Tree type = node.getType();
2323-
if (varargs) {
2324-
if (type instanceof AnnotatedTypeTree) {
2325-
varargsAnnotations = ((AnnotatedTypeTree) type).getAnnotations();
2326-
type = ((AnnotatedTypeTree) type).getUnderlyingType();
2327-
}
2328-
type = ((ArrayTypeTree) type).getType();
2329-
}
23302323
declareOne(
23312324
kind,
23322325
annotationsDirection,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class B38203081 {
2+
void f(int @A []... xs) {}
3+
4+
void g(int @A [] @B... xs) {}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class B38203081 {
2+
void f(int @A []... xs) {}
3+
4+
void g(int @A [] @B... xs) {}
5+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class I95 {
2-
public void format2(Object @Nullable ... a2) {}
2+
public void format2(Object @Nullable... a2) {}
33
}

0 commit comments

Comments
 (0)