Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
When we develop AST transformations, it is often difficult to check that a particular transformation performs what is necessary. For example, we would like, in type checking, to verify that after the type checker has performed its work, a particular AST node contains metadata about the inferred type. Checking this currently requires compilation trickery which is not user-friendly. We propose to add an AST transformation which allows embedding tests. For example, we could test the @Field AST transformation this way:
import groovy.transform.* @ASTTest(value = { def owner = node.declaringClass assert owner.fields.any { it.name == 'x' } } @Field int x