[
https://issues.apache.org/jira/browse/GROOVY-11386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles resolved GROOVY-11386.
----------------------------------
Fix Version/s: 5.0.0-alpha-9
Resolution: Fixed
https://github.com/apache/groovy/commit/5ddc1a0a0ea20ceb85aa834a8a1e6bf19cb76e80
> STC: closure property precedence
> --------------------------------
>
> Key: GROOVY-11386
> URL: https://issues.apache.org/jira/browse/GROOVY-11386
> 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: Minor
> Fix For: 5.0.0-alpha-9
>
>
> Properties within a closure are satisfied first against the closure followed
> by the resolve strategy. This is implemented by:
> https://github.com/apache/groovy/blob/0e8718d6bafba61daf962892c9d7ae10832b62e0/src/main/java/groovy/lang/Closure.java#L280
> The type checker supports this here:
> https://github.com/apache/groovy/blob/0e8718d6bafba61daf962892c9d7ae10832b62e0/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L648
> The properties "class" and "metaClass" are missing from the switch. "class"
> is not possible as a variable. However, "metaClass" is and should refer to
> the Closure's meta class, not the delegate or owner's meta class. This can
> be checked by running:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test(object) {
> object.with {
> print metaClass
> }
> }
> test("")
> {code}
> This script should print something like
> "org.codehaus.groovy.runtime.metaclass.ClosureMetaClass@17d2ed1b[class
> Sample$_test_closure1]".
--
This message was sent by Atlassian Jira
(v8.20.10#820010)