Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.7, 2.4.10
-
None
Description
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:
@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') } }
Tested with Groovy 2.4.7 and 2.4.10