Roman Saveljev created GROOVY-7686:
--------------------------------------

             Summary: Can not see local variable from overriden method called 
from the constructor of an anonymous class instance
                 Key: GROOVY-7686
                 URL: https://issues.apache.org/jira/browse/GROOVY-7686
             Project: Groovy
          Issue Type: Bug
          Components: Compiler, groovy-runtime
    Affects Versions: 2.4.5
         Environment: Linux
            Reporter: Roman Saveljev


Reduced code showing the problem: 
https://gist.github.com/RomanSaveljev/71ed29b0df3eb306485c

In the runtime it fails with:

{noformat}
Caught: java.lang.NullPointerException
java.lang.NullPointerException
        at bug$1.func(bug.groovy:14)
        at A.<init>(bug.groovy:3)
        at bug$1.<init>(bug.groovy)
        at bug.func(bug.groovy:11)
        at bug.run(bug.groovy:22)
{noformat}

It happens, because inside the overriden method it tries to access locally 
defined {{t}}. I have translated the same code to Java (see the gist) and it 
works as expected.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to