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

NamedVariant: non-trivial default value of NamedDelegate property

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      import groovy.transform.*
      
      @ToString
      class Pogo {
          private static V = 42
          Number n = V
      }
      
      @NamedVariant(autoDelegate=true)
      void test(Pogo p) {
          print p
      }
      
      test([:]) // MissingPropertyException: No such property: V for class: script
      

      Variable expression "V" is transferred from scope of Pogo to generated method test(Map)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h