Package org.apache.groovy.contracts.ast

# Class ModifiesEnsuresValidationTransformation

java.lang.Object
org.apache.groovy.contracts.ast.ModifiesEnsuresValidationTransformation

All Implemented Interfaces:
  `ASTTransformation`

public class ModifiesEnsuresValidationTransformation extends Object implements ASTTransformation
Validates that `@Ensures` postconditions on a method only reference fields via `old.xxx` that are declared as modifiable by `@Modifies`.

Runs at `CompilePhase.INSTRUCTION_SELECTION` after both:

- `ModifiesASTTransformation` has stored the modification set, and
- `AnnotationClosureVisitor` has recorded the `old` references

Then simply compares the two metadata sets.

Since:
  6.0.0
See Also:
  - `Modifies`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ModifiesEnsuresValidationTransformation()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `visit(ASTNode[] nodes, SourceUnit source)`
  Validates that `old` references used by `@Ensures` stay within the state declared by `@Modifies`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ModifiesEnsuresValidationTransformation

    public ModifiesEnsuresValidationTransformation()

- ## Method Details

  - ### visit

    public void visit(ASTNode[] nodes, SourceUnit source)
    Validates that `old` references used by `@Ensures` stay within the state declared by `@Modifies`.
    Specified by:
      `visit` in interface `ASTTransformation`
    Parameters:
      `nodes` - the annotated AST nodes supplied by the compiler
      `source` - the current source unit