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

Access to static fields/properties from within nested classes is inconsistent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4.8
    • None
    • None

    Description

      Misbehaves in the same way regardless of @CompileStatic:

      import java.util.logging.Logger
      
      //@groovy.transform.CompileStatic
      class Foo {
      
        private static final transient Logger log = Logger.getLogger(Foo.class.getName()) 
        void method() {
          log.info('some info')
        }
        static class Bar {
          void method() {
            log.info('some inner info')
          }
          static class Baz {
             void method() {
              log.info('some inner inner info')
            }
          }
        }
      }
      
      new Foo().method() // => INFO: some info
      new Foo.Bar().method() // => INFO: some inner info
      new Foo.Bar.Baz().method() // => groovy.lang.MissingPropertyException: No such property: log for class: Foo$Bar
      

      Attachments

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: