Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
The current implementation expects to be given a ClassExpression for each class to Newify (for the Rubyesque style). Classes defined within the same script won't yet be processed into a ClassExpression but can be found in the source unit. The goal is to make the following work:
import groovy.transform.Immutable abstract class Tree {} @Immutable class Branch extends Tree { Tree left, right } @Immutable class Leaf extends Tree { int val } @Newify([Branch, Leaf]) def t = Branch(Leaf(1), Branch(Branch(Leaf(2), Leaf(3)), Leaf(4))) assert t.toString() == 'Branch(Leaf(1), Branch(Branch(Leaf(2), Leaf(3)), Leaf(4)))'