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 19:09:00 UTC

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

     [ https://issues.apache.org/jira/browse/GROOVY-11401?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-11401:
---------------------------------
    Description: 
Consider the following:
{code:groovy}
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()
{code}

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

GROOVY-11367

  was:
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


> 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: 3.0.21, 4.0.21
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> 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()
> {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)