You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/03/06 23:13:01 UTC

[jira] [Closed] (GROOVY-8130) Cannot call private constructor error - @CompileStatic & default method argument

     [ https://issues.apache.org/jira/browse/GROOVY-8130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-8130.
-----------------------------

> 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.7, 2.4.10
>            Reporter: Marcin Zajaczkowski
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 2.4.13
>
>
> 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
(v7.6.3#76005)