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

STC: type inference of variable expression with superclass field and access method

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      abstract class A {
        protected Object thing = 'field'
        String getThing() { 'property' }
      }
      @groovy.transform.CompileStatic
      class C extends A {
        void test() {
          print thing.toUpperCase()
        }
      }
      new C().test()
      

      If ".toUpperCase()" is removed, the script prints "property". However the STC type recorded comes from the field.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment