You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Aleksandr Kazakov (Jira)" <ji...@apache.org> on 2019/12/31 21:29:00 UTC

[jira] [Comment Edited] (GROOVY-9120) Anonymous class enclosing reference broken in 2.5.7

    [ https://issues.apache.org/jira/browse/GROOVY-9120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17006231#comment-17006231 ] 

Aleksandr Kazakov edited comment on GROOVY-9120 at 12/31/19 9:28 PM:
---------------------------------------------------------------------

Hi,

[~emilles], I found the same issue. Here is my example.
 Working in 2.5.6, not working in 2.5.7 and 2.5.8
{code:java}
import java.util.function.Supplier

class ReproduceBug {
    interface Module {
        Runnable runnable()
        Supplier<Long> numberSupplier()
    }

    static Module newModule() {
        long number = 1

        return new Module() {

            @Override
            Runnable runnable() {
                return {
                    println("number is ${number}")
                }
            }

            @Override
            Supplier<Long> numberSupplier() {
                return { number }
            }
        }
    }

    static void main(String[] args) {
        def module = newModule()
        println('number is ' + module.numberSupplier().get())
    }
}
{code}
version 2.5.6 prints
{noformat}
number is 1
{noformat}
versions 2.5.7 and 2.5.8 print
{noformat}
number is groovy.lang.Reference@32502377
{noformat}


was (Author: alexkazakov90):
Hi,

I found the same issue. Here is my example.
Working in 2.5.6, not working in 2.5.7 and 2.5.8

{code:java}
import java.util.function.Supplier

class ReproduceBug {
    interface Module {
        Runnable runnable()
        Supplier<Long> numberSupplier()
    }

    static Module newModule() {
        long number = 1

        return new Module() {

            @Override
            Runnable runnable() {
                return {
                    println("number is ${number}")
                }
            }

            @Override
            Supplier<Long> numberSupplier() {
                return { number }
            }
        }
    }

    static void main(String[] args) {
        def module = newModule()
        println('number is ' + module.numberSupplier().get())
    }
}
{code}

version 2.5.6 prints
{noformat}
number is 1
{noformat}

versions 2.5.7 and 2.5.8 print
{noformat}
number is groovy.lang.Reference@32502377
{noformat}



> Anonymous class enclosing reference broken in 2.5.7
> ---------------------------------------------------
>
>                 Key: GROOVY-9120
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9120
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.7
>            Reporter: Romain Manni-Bucau
>            Priority: Major
>
> Follow up ticket of "2.5.7 regression with references?" mail.
> Using a ref defined outside an anonymous class frol the inner class is considered typed as "Reference" making it impossible to use in any java method now. It was working fine in 2.5.6.
> There is an example referenced in the dev list mail but it should be straight forward to reproduce.



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