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/10/10 16:29:00 UTC

[jira] [Assigned] (GROOVY-10265) STC is unable to resolve variable in closure

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

Eric Milles reassigned GROOVY-10265:
------------------------------------

    Assignee: Eric Milles

> STC is unable to resolve variable in closure
> --------------------------------------------
>
>                 Key: GROOVY-10265
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10265
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>
> I have the following program
> {code:java}
> import java.util.function.Supplier;
> class B {
>   Supplier<Integer> m2() {
>     final def x = 1
>     { -> x + 1 }
>   }
> }
> {code}
> h3. Actual behaviour
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 5: [Static type checking] - Cannot find matching method int#call(groovy.lang.Closure). Please check if the declared type is correct and if the method exists.
>  @ line 5, column 19.
>        final def x = 1
>                      ^test.groovy: 6: [Static type checking] - The variable [x] is undeclared.
>  @ line 6, column 10.
>        { -> x + 1 }
>             ^test.groovy: 5: [Static type checking] - Cannot return value of type java.lang.Object on method returning type java.util.function.Supplier<java.lang.Integer>
>  @ line 5, column 5.
>        final def x = 1
>        ^3 errors
> {code}
> h3. Expected behaviour
> Compile successfully
>  
> Tested against master



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