Class ModifiabilityBaseVisitor

All Implemented Interfaces:
TreeVisitor<Void,Void>
Direct Known Subclasses:
IteratorVisitor

public class ModifiabilityBaseVisitor extends BaseTypeVisitor<ModifiabilityBaseAnnotatedTypeFactory>
Base visitor for the modifiability sub-checkers (Grow, SeqGrow, Shrink, Replace, and Iterator).

This class contains logic shared across all the sub-checkers:

  • Suppressing the "constructor result must be TOP" check, since collection constructors may legitimately produce @Modifiable.
  • Suppressing the rule that relates a constructor's result to that of the this() or super() call within it, since a class may declare a different modifiability than its superclass does.
  • Requiring all the constructors of a class to declare the same result qualifier, and requiring the body of each method that requires the capability -- either on its own receiver parameter or from a method that it overrides -- to agree with that qualifier about whether the method throws UnsupportedOperationException.
  • Requiring a concrete class that claims the capability not to inherit, without overriding, a method whose implementation always throws UnsupportedOperationException.
  • Requiring an override to preserve a positive receiver capability of the method it overrides.