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 2020/11/21 00:21:00 UTC

[jira] [Resolved] (GROOVY-7020) Problem With "this" Inside Of Anonymous Inner Class

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

Eric Milles resolved GROOVY-7020.
---------------------------------
    Resolution: Fixed

> Problem With "this" Inside Of Anonymous Inner Class
> ---------------------------------------------------
>
>                 Key: GROOVY-7020
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7020
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.3.3, 2.4.1
>            Reporter: Jeff Brown
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 3.0.0, 2.5.7
>
>
> If an anonymous inner class is defined inside of a static method, "this" does not reference what it should:
> {code:title=Demo.groovy|borderStyle=solid}
> class Demo {
>     static void main(arg) {
>         def r = new Runnable() {
>             void run() {
>                 if(this instanceof Runnable) {
>                     println 'Yep'
>                 } else {
>                     println 'Nope'
>                 }
>             }
>         }
>         r.run()
>     }
> }
> {code}
> {noformat}
> $ groovy Demo
> Nope
> {noformat}
> 2.3.3 is the only version I have tested this with.



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