You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2024/06/10 18:33:00 UTC

[jira] [Created] (GROOVY-11401) STC: inferred type of name within closure (delegate property versus owner field)

Eric Milles created GROOVY-11401:
------------------------------------

             Summary: STC: inferred type of name within closure (delegate property versus owner field)
                 Key: GROOVY-11401
                 URL: https://issues.apache.org/jira/browse/GROOVY-11401
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
    Affects Versions: 4.0.21, 3.0.21
            Reporter: Eric Milles
            Assignee: Eric Milles


Consider the following:
{code:groovy}
class C {
  private Object obj = 'field'
  @groovy.transform.TypeChecked
  void test() {
    def map = [:].withDefault{ 'entry' }
    map.with {
      def x = obj
      print x
    }
  }
}
new C().test()
{code}

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

GROOVY-11367



--
This message was sent by Atlassian Jira
(v8.20.10#820010)