Skip to content

Commit

Permalink
Don't crash on type annotated varargs parameters
Browse files Browse the repository at this point in the history
Fixes #95

MOE_MIGRATED_REVID=139810602
  • Loading branch information
cushon committed Nov 21, 2016
1 parent 3c3dcae commit ba12d25
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Expand Up @@ -2307,13 +2307,22 @@ private void visitToDeclare(
Optional<String> trailing) { Optional<String> trailing) {
sync(node); sync(node);
boolean varargs = (((JCTree.JCVariableDecl) node).mods.flags & Flags.VARARGS) == Flags.VARARGS; boolean varargs = (((JCTree.JCVariableDecl) node).mods.flags & Flags.VARARGS) == Flags.VARARGS;
List<? extends AnnotationTree> varargsAnnotations = ImmutableList.of();
Tree type = node.getType();
if (varargs) {
if (type instanceof AnnotatedTypeTree) {
varargsAnnotations = ((AnnotatedTypeTree) type).getAnnotations();
type = ((AnnotatedTypeTree) type).getUnderlyingType();
}
type = ((ArrayTypeTree) type).getType();
}
declareOne( declareOne(
kind, kind,
annotationsDirection, annotationsDirection,
Optional.of(node.getModifiers()), Optional.of(node.getModifiers()),
varargs ? ((ArrayTypeTree) node.getType()).getType() : node.getType(), type,
VarArgsOrNot.valueOf(varargs), VarArgsOrNot.valueOf(varargs),
/*varargsAnnotations=*/ ImmutableList.<AnnotationTree>of(), varargsAnnotations,
node.getName(), node.getName(),
"", "",
equals, equals,
Expand Down Expand Up @@ -2956,7 +2965,7 @@ int declareOne(
Optional<ModifiersTree> modifiers, Optional<ModifiersTree> modifiers,
Tree type, Tree type,
VarArgsOrNot isVarargs, VarArgsOrNot isVarargs,
List<AnnotationTree> varargsAnnotations, List<? extends AnnotationTree> varargsAnnotations,
Name name, Name name,
String op, String op,
String equals, String equals,
Expand Down
@@ -0,0 +1,3 @@
class I95 {
public void format2(Object @Nullable ... a2) {}
}
@@ -0,0 +1,3 @@
class I95 {
public void format2(Object @Nullable ... a2) {}
}

0 comments on commit ba12d25

Please sign in to comment.