Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8275

Newify transform docs missing support for local variable declaration

    XMLWordPrintableJSON

Details

    • Documentation
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • xforms
    • None

    Description

      Javadocs and online documentation for the Newify AST transform is not quite clear in a couple instances.

      1) Online docs http://groovy-lang.org/metaprogramming.html#xform-Newify Ruby-style section could be more clear IMO if the ([Tree,Leaf]) were removed since it only enables the Python-style expressions.

      2) Javadoc and online docs do not mention that @Newify can be applied to a local variable declaration, like: @Newify def o = Object.new().

      3) The scoping of the transform is pretty clear for the class, method and field/property cases. However for the local variable case, it appears that the transform applies throughout the containing scope of the local variable. That is, I can use the extra constructors anywhere in the block to re-initialize the variable. @Newify def o = Object.new(); ... o = Object.new() .... Is this the intended behavior? My intuition was that the initializer expression was the only place the transform applied, like in the case of a field.

      Attachments

        Activity

          People

            Unassigned Unassigned
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: