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

SC: implicit-this reference to outer class super property produces access error

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      public class JavaBean<T> {
          private T value;
          public T getValue() {
              return value;
          }
          public void setValue(T value) {
              this.value = value;
          }
      }
      
      @groovy.transform.CompileStatic
      class Outer extends groovy.transform.stc.JavaBean<Inner> {
        static class Inner {
          String string
        }
        def bar() {
          { -> value.string }.call() // "value" is parameterized property
        }
      }
      
      def foo = new Outer(value: new Outer.Inner(string:'hello world'))
      assert foo.bar() == 'hello world'
      

      "Access to T#string is forbidden"

      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: