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 2020/12/07 22:10:03 UTC
[jira] [Closed] (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 ]
Paul King closed GROOVY-7020.
-----------------------------
> 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: 2.5.7, 3.0.0
>
>
> 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)