File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
main/java/com/google/googlejavaformat/java
test/resources/com/google/googlejavaformat/java/testdata Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -2307,13 +2307,22 @@ private void visitToDeclare(
23072307 Optional <String > trailing ) {
23082308 sync (node );
23092309 boolean varargs = (((JCTree .JCVariableDecl ) node ).mods .flags & Flags .VARARGS ) == Flags .VARARGS ;
2310+ List <? extends AnnotationTree > varargsAnnotations = ImmutableList .of ();
2311+ Tree type = node .getType ();
2312+ if (varargs ) {
2313+ if (type instanceof AnnotatedTypeTree ) {
2314+ varargsAnnotations = ((AnnotatedTypeTree ) type ).getAnnotations ();
2315+ type = ((AnnotatedTypeTree ) type ).getUnderlyingType ();
2316+ }
2317+ type = ((ArrayTypeTree ) type ).getType ();
2318+ }
23102319 declareOne (
23112320 kind ,
23122321 annotationsDirection ,
23132322 Optional .of (node .getModifiers ()),
2314- varargs ? (( ArrayTypeTree ) node . getType ()). getType () : node . getType () ,
2323+ type ,
23152324 VarArgsOrNot .valueOf (varargs ),
2316- /* varargsAnnotations=*/ ImmutableList .< AnnotationTree > of () ,
2325+ varargsAnnotations ,
23172326 node .getName (),
23182327 "" ,
23192328 equals ,
@@ -2956,7 +2965,7 @@ int declareOne(
29562965 Optional <ModifiersTree > modifiers ,
29572966 Tree type ,
29582967 VarArgsOrNot isVarargs ,
2959- List <AnnotationTree > varargsAnnotations ,
2968+ List <? extends AnnotationTree > varargsAnnotations ,
29602969 Name name ,
29612970 String op ,
29622971 String equals ,
Original file line number Diff line number Diff line change 1+ class I95 {
2+ public void format2(Object @Nullable ... a2) {}
3+ }
Original file line number Diff line number Diff line change 1+ class I95 {
2+ public void format2(Object @Nullable ... a2) {}
3+ }
You can’t perform that action at this time.
0 commit comments