Groovy
  1. Groovy
  2. GROOVY-4876

@Newify works for pre-defined classes but not for classes defined in the same script

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.1
    • Component/s: None
    • Labels:
      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)))'
      

        Activity

        paulk@asert.com.au created issue -
        Paul King made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Paul King made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s 1.8.1 [ 17223 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733803 ] Default workflow, editable Closed status [ 12745621 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971349 ] Default workflow, editable Closed status [ 12979112 ]
        Mark Thomas made changes -
        Reporter Paul King [ paulk@asert.com.au ] Paul King [ paulk ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        1h 5m 1 Paul King 12/Jun/11 09:27
        Resolved Resolved Reopened Reopened
        29s 1 Paul King 12/Jun/11 09:28
        Reopened Reopened Resolved Resolved
        11s 1 Paul King 12/Jun/11 09:28
        Resolved Resolved Closed Closed
        39d 10h 38m 1 Paul King 21/Jul/11 20:06

          People

          • Assignee:
            Paul King
            Reporter:
            Paul King
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development