@Override
    public Void visitTypeCast(TypeCastTree node, AnnotatedTypeMirror p) {

      if (!p.isAnnotated()) {
        // check if it is casting "this"
        if (TreeUtils.skipParens(node.getExpression()).toString().equals("this")) {
          annotateThis(p);
        }
      }

      return super.visitTypeCast(node, p);
    }
 @Override
 public Void visitVariable(VariableTree node, AnnotatedTypeMirror p) {
   typeAnnotator.visit(p);
   VariableElement varElt = TreeUtils.elementFromDeclaration((VariableTree) node);
   if (!p.isAnnotated() && ElementUtils.isStatic(varElt)) {
     p.clearAnnotations();
     Set<AnnotationMirror> set = AnnotationUtils.createAnnotationSet();
     set.add(checker.ANY);
     set.add(checker.PEER);
     annotateConstants(p, set);
   }
   return super.visitVariable(node, p);
 }
  @Override
  public boolean isAssignable(AnnotatedTypeMirror varType, Tree varTree) {
    if (varTree.getKind() == Tree.Kind.VARIABLE || varType.hasAnnotation(ASSIGNABLE)) return true;

    Element varElement = InternalUtils.symbol(varTree);
    if (varElement == null || !varElement.getKind().isField() || ElementUtils.isStatic(varElement))
      return true;

    ExpressionTree expTree = (ExpressionTree) varTree;
    AnnotatedTypeMirror receiver = factory.getReceiver(expTree);

    boolean isAssignable =
        receiver.hasAnnotation(MUTABLE)
            || (receiver.hasAnnotation(ASSIGNS_FIELDS) && TreeUtils.isSelfAccess(expTree));

    return isAssignable;
  }
 @Override
 public AnnotatedTypeMirror getAnnotatedType(Tree tree) {
   AnnotatedTypeMirror type = super.getAnnotatedType(tree);
   if (tree instanceof ExpressionTree) tree = TreeUtils.skipParens((ExpressionTree) tree);
   Element elt = InternalUtils.symbol(tree);
   if (!checker.isChecking() /*&& !checker.isDefaultAnyType(type)*/
       && type.isAnnotated()
       && !type.getKind().isPrimitive()
       && type.getKind() != TypeKind.NULL
       && (elt == null || !ElementUtils.isStatic(elt))) {
     // We don't want annotations on the following trees
     Kind kind = tree.getKind();
     if (kind == Kind.METHOD_INVOCATION
         || kind == Kind.ARRAY_ACCESS
         || kind == Kind.MEMBER_SELECT
         || kind == Kind.CONDITIONAL_EXPRESSION) {
       type = type.getCopy(false);
     }
   }
   return type;
 }