Graeme Rocher created GROOVY-7970:

             Summary: Can't call private method from outer class when using 
inner classes and @CS
                 Key: GROOVY-7970
             Project: Groovy
          Issue Type: Bug
            Reporter: Graeme Rocher

This example:

import groovy.json.*
import groovy.transform.*

class Bar {
    private Writable renderTemplate(Object o, Map args) {
    def foo(Map map, Map arguments) {
        def writable = new Writable() {
            Writer writeTo(Writer out) throws IOException {
                StreamingJsonBuilder builder = new StreamingJsonBuilder(out)
                    for(key in map.keySet()) {
                        def o = map.get(key)
                        Writable writable = renderTemplate((Object)o, arguments)
                        call(key.toString(), writable)
                return out

writable = new Bar().foo([one:'two'],[foo:'bar'])

sw = new StringWriter()
println sw

Results in a compilation error:

[Static type checking] - Cannot find matching method 
Bar$1#renderTemplate(java.lang.Object, java.util.Map). Please check if the 
declared type is right and if the method exists.
 at line: 18, column: 45

If you attempt to use {{Bar.this}}:

Writable writable = Bar.this.renderTemplate((Object)o, arguments)

The result is a VerifierError

java.lang.VerifyError: (class: Bar$1$_writeTo_closure1, method: doCall 
signature: (Ljava/lang/Object;)Ljava/lang/Object;) Incompatible argument to 
        at Bar$1.writeTo(ConsoleScript11:15)
        at groovy.lang.Writable$ Source)

This message was sent by Atlassian JIRA

Reply via email to