paolo di tommaso created GROOVY-8978:
----------------------------------------

             Summary: NPE when accessing protected method from subclass clone
                 Key: GROOVY-8978
                 URL: https://issues.apache.org/jira/browse/GROOVY-8978
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.5.6
            Reporter: paolo di tommaso


I'm getting a NPE when running this snippet: 

{code}
@groovy.transform.CompileStatic
class LazyMap implements Map<String,Object> {

    @Delegate protected Map<String,Object> target

    LazyMap() {
        target = new HashMap<>()
    }
}

@groovy.transform.CompileStatic
class TaskConfig extends LazyMap implements Cloneable {

    TaskConfig() {  }

    TaskConfig clone() {
        def copy = (TaskConfig)super.clone()
        copy.target = new HashMap<>(this.target)
        return copy
    }
}
{code}

The problem is that `this.target` in the clone method is evaluated to `null`. 
It works fine if the classes are not declared CompileStatic. It was also 
working fine with groovy version prior to 2.5.6. 

 




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to