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 2021/09/09 16:09:00 UTC

[jira] [Assigned] (GROOVY-10219) Closure type for local var is inferred, but unavailable to Closure's contents

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

Eric Milles reassigned GROOVY-10219:
------------------------------------

    Assignee: Eric Milles

> Closure type for local var is inferred, but unavailable to Closure's contents
> -----------------------------------------------------------------------------
>
>                 Key: GROOVY-10219
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10219
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 3.0.8
>            Reporter: Svatopluk Dedic
>            Assignee: Eric Milles
>            Priority: Major
>
> {code:java}
> @groovy.transform.CompileStatic
> class A {
>         def err() {
>                 // should be inferenced to Closure
>                 def cl
>                 cl = {
>                         assert cl.delegate != null;   // This errors out
>                 };
>                 assert cl.delegate != null;           // This works OK
>         }
> }
> new A().err()
> {code}
> It appears as the closure's type is stored/inferred only after the type checker finishes the Closure's AST subtree. But regardless of possible parameters (and their types) and/or return type, the whole expression is always assignable to Closure, so the Closure's contents should be able to work with its delegate/owner properties.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)