Marcin Zajaczkowski created GROOVY-8130:
-------------------------------------------

             Summary: Cannot call private constructor error - @CompileStatic & 
default method argument
                 Key: GROOVY-8130
                 URL: https://issues.apache.org/jira/browse/GROOVY-8130
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 2.4.10, 2.4.7
            Reporter: Marcin Zajaczkowski
            Priority: Minor


Groovy compiler reports error on a try of use private constructor with default 
method argument from a static method:
Error:(15, 16) Groovyc: Cannot call private constructor for 
com.ofg.test.CannotCallPrivateConstructorIssueReproductor from class 
com.ofg.test.CannotCallPrivateConstructorIssueReproductor

Sample code to reproduce that issue:
{code}
@CompileStatic
class CannotCallPrivateConstructorIssueReproductor {

    private final String someFiled //final is NOT mandatory to reproduce the 
issue

    private CannotCallPrivateConstructorIssueReproductor(String someFiled, 
Integer optionalArgument = null) {   //field with default value is crutial
        this.someFiled = someFiled
    }

    static CannotCallPrivateConstructorIssueReproductor factoryMethod() {
        return new CannotCallPrivateConstructorIssueReproductor('sth')
    }
}
{code}

Tested with Groovy 2.4.7 and 2.4.10



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to