@Override
 public void visit(Tree.BaseMemberExpression bme) {
   if (annotationConstructor != null) {
     Declaration declaration = bme.getDeclaration();
     if (checkingInvocationPrimary && isAnnotationConstructor(bme.getDeclaration())) {
       Method ctor = (Method) bme.getDeclaration();
       instantiation.setPrimary(ctor);
       if (ctor.getAnnotationConstructor() != null) {
         instantiation
             .getConstructorParameters()
             .addAll(
                 ((AnnotationInvocation) ctor.getAnnotationConstructor())
                     .getConstructorParameters());
       }
     } else if (checkingArguments || checkingDefaults) {
       if (declaration instanceof Value && ((Value) declaration).isParameter()) {
         Value constructorParameter = (Value) declaration;
         ParameterAnnotationTerm a = new ParameterAnnotationTerm();
         a.setSpread(spread);
         // XXX Is this right?
         a.setSourceParameter(constructorParameter.getInitializerParameter());
         this.term = a;
       } else if (isBooleanTrue(declaration)) {
         LiteralAnnotationTerm argument = new BooleanLiteralAnnotationTerm(true);
         appendLiteralArgument(bme, argument);
       } else if (isBooleanFalse(declaration)) {
         LiteralAnnotationTerm argument = new BooleanLiteralAnnotationTerm(false);
         appendLiteralArgument(bme, argument);
       } else if (bme.getUnit().isEmptyType(bme.getTypeModel())
           && bme.getUnit().isIterableType(bme.getTypeModel())
           && elements == null) {
         // If we're dealing with an iterable, empty means empty collection, not object
         endCollection(startCollection(bme), bme);
       } else if (Decl.isAnonCaseOfEnumeratedType(bme)) {
         LiteralAnnotationTerm argument = new ObjectLiteralAnnotationTerm(bme.getTypeModel());
         appendLiteralArgument(bme, argument);
       } else {
         bme.addError(
             "compiler bug: unsupported base member expression in annotation constructor");
       }
     } else {
       bme.addError("compiler bug: unsupported base member expression in annotation constructor");
     }
   }
 }
 @Override
 public void visit(Tree.BaseTypeExpression bte) {
   if (annotationConstructor != null) {
     if (isAnnotationClass(bte.getDeclaration())) {
       instantiation.setPrimary((Class) bte.getDeclaration());
     } else {
       bte.addError("compiler bug: not an annotation class");
     }
   }
 }
 @Override
 public void visit(Tree.MethodDeclaration d) {
   if (isAnnotationConstructor(d) && d.getSpecifierExpression() != null) {
     annotationConstructor = d;
     instantiation = new AnnotationInvocation();
     instantiation.setConstructorDeclaration(d.getDeclarationModel());
     d.getDeclarationModel().setAnnotationConstructor(instantiation);
   }
   super.visit(d);
   if (isAnnotationConstructor(d) && d.getSpecifierExpression() != null) {
     instantiation = null;
     annotationConstructor = null;
   }
 }
 @Override
 public void visit(Tree.ListedArgument argument) {
   if (annotationConstructor != null && this.elements == null) {
     AnnotationArgument aa = new AnnotationArgument();
     aa.setParameter(argument.getParameter());
     push(aa);
     argument.getExpression().visit(this);
     aa.setTerm(this.term);
     instantiation.getAnnotationArguments().add(aa);
     this.term = null;
     pop();
   } else {
     super.visit(argument);
   }
 }
  @Override
  public void visit(Tree.Parameter p) {

    if (annotationConstructor != null) {
      AnnotationConstructorParameter acp = new AnnotationConstructorParameter();
      acp.setParameter(p.getParameterModel());
      instantiation.getConstructorParameters().add(acp);
      push(acp);
      // super.visit(p);
      Tree.SpecifierOrInitializerExpression defaultArgument = Decl.getDefaultArgument(p);
      if (defaultArgument != null) {
        defaultedParameter(defaultArgument);
      }
      pop();
      Tree.ValueParameterDeclaration vp;
    }
    // Ignore statements in parameters
  }
  public void defaultedParameter(Tree.SpecifierOrInitializerExpression d) {
    if (annotationConstructor != null) {
      AnnotationConstructorParameter annotationConstructorParameter =
          instantiation
              .getConstructorParameters()
              .get(instantiation.getConstructorParameters().size() - 1);

      Declaration t = d.getUnit().getTrueValueDeclaration();
      Declaration f = d.getUnit().getFalseValueDeclaration();
      Term term = d.getExpression().getTerm();
      if (term instanceof Tree.InvocationExpression) {
        Tree.Primary primary = ((Tree.InvocationExpression) term).getPrimary();
        if (primary instanceof Tree.BaseMemberOrTypeExpression
            && (isAnnotationConstructor(
                    ((Tree.BaseMemberOrTypeExpression) primary).getDeclaration())
                || isAnnotationClass(
                    ((Tree.BaseMemberOrTypeExpression) primary).getDeclaration()))) {
          final AnnotationInvocation prevInstantiation = this.instantiation;
          this.instantiation = new AnnotationInvocation();
          if (isAnnotationConstructor(
              ((Tree.BaseMemberOrTypeExpression) primary).getDeclaration())) {
            Method constructor =
                (Method) ((Tree.BaseMemberOrTypeExpression) primary).getDeclaration();
            instantiation.setConstructorDeclaration(constructor);
            instantiation
                .getConstructorParameters()
                .addAll(
                    ((AnnotationInvocation) constructor.getAnnotationConstructor())
                        .getConstructorParameters());
          }
          checkingDefaults = true;

          super.visit(d);

          annotationConstructorParameter.setDefaultArgument(this.term);
          this.term = null;
          checkingDefaults = false;
          this.instantiation = prevInstantiation;
        } else {
          errorDefaultedParameter(d);
        }
      } else if (term instanceof Tree.Literal
          || (term instanceof Tree.BaseMemberExpression
              && (((Tree.BaseMemberExpression) term).getDeclaration().equals(t)
                  || ((Tree.BaseMemberExpression) term).getDeclaration().equals(f)
                  || ((Tree.BaseMemberExpression) term).getDeclaration().isParameter()
                  || Decl.isAnonCaseOfEnumeratedType((Tree.BaseMemberExpression) term)))) {
        checkingDefaults = true;

        super.visit(d);

        annotationConstructorParameter.setDefaultArgument(this.term);
        this.term = null;
        checkingDefaults = false;
      } else if (term instanceof Tree.Tuple || term instanceof Tree.SequenceEnumeration) {
        // TODO Tuples and SequenceEnumerations of the above cases should also be allowed
        checkingDefaults = true;

        super.visit(d);

        annotationConstructorParameter.setDefaultArgument(this.term);
        this.term = null;
        checkingDefaults = false;
      } else {
        errorDefaultedParameter(d);
      }
    }
  }