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

reference to outer class non-private static field before special ctor call

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      class Outer {
          @groovy.transform.CompileStatic
          static class Inner {
              public final String value
              Inner(String string) {
                  value = string
              }
              Inner() {
                  this(VALUE.toString())
              }
          }
          public static Integer VALUE = 42
          static main(args) {
              assert new Inner().value == '42'
          }
      }
      

      The expression "this(VALUE.toString())" throws a cast exception at runtime. It is compiled to this.getProperty("VALUE") – however "this" is static at the point.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: