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

STC: inferred type of name within closure (delegate property versus owner field)

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      class C {
        private Object obj = 'field'
        @groovy.transform.TypeChecked
        void test() {
          Map<String,String> map = [:].withDefault{ 'entry' }
          map.with {
            def x = obj
            print x
          }
        }
      }
      new C().test()
      

      This script prints "entry" but the inferred type of "x" is Object not String.

      GROOVY-11367

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: