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

Using subscript operator on properties with a Builder and @DelegatesTo doesn't work

    XMLWordPrintableJSON

Details

    Description

      We get Groovyc: [Static type checking] - The variable [attrs] is undeclared. in the following scenario:

      import groovy.transform.CompileStatic
      import static groovy.lang.Closure.*
      
      @CompileStatic
      class DatasourceBuilder {
      
          Map<String,String> attrs = [:]
      }
      
      
      void datasource(@DelegatesTo(strategy = DELEGATE_FIRST, value = DatasourceBuilder) Closure c) {}
      
      @CompileStatic
      void foo() {
         datasource {
             attrs['some'] = 'foo'
         }
      }
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            pred Stéphane Maldini
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: