[
https://issues.apache.org/jira/browse/GROOVY-11401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17854183#comment-17854183
]
Eric Milles commented on GROOVY-11401:
--------------------------------------
Code like the example under static compilation will exhibit different behavior.
Map entry will be read or written instead of member from enclosing context.
> 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, 5.0.0-alpha-8, 4.0.21
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Major
> Labels: breaking
> Fix For: 3.0.22, 5.0.0-alpha-9, 4.0.22
>
>
> 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)