You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2024/11/12 11:41:00 UTC
[jira] [Closed] (GROOVY-11386) STC: closure property precedence
[ https://issues.apache.org/jira/browse/GROOVY-11386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-11386.
------------------------------
> 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)