[ 
https://issues.apache.org/jira/browse/GROOVY-7932?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15578506#comment-15578506
 ] 

ASF GitHub Bot commented on GROOVY-7932:
----------------------------------------

GitHub user shils opened a pull request:

    https://github.com/apache/groovy/pull/449

    GROOVY-7932: generate bridge methods for private constructors during …

    …static compilation

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shils/groovy GROOVY-7932

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/449.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #449
    
----
commit 7b0b5f81b9bffc0c3223ae18921d7f23bca83f96
Author: Shil Sinha <sh...@apache.org>
Date:   2016-10-09T20:57:47Z

    GROOVY-7932: generate bridge methods for private constructors during static 
compilation

----


> Cannot call private constructor from closures with @CompileStatic
> -----------------------------------------------------------------
>
>                 Key: GROOVY-7932
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7932
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.7, 2.5.x
>         Environment: Ubuntu 16.04
> openjdk version "1.8.0_91"
>            Reporter: Cazacu Mihai
>            Assignee: Shil Sinha
>
> {code:title=Test.groovy|borderStyle=solid}
> import groovy.transform.CompileStatic
> @CompileStatic
> interface Handler<E> {
>     void handle(E event)
> }
> @CompileStatic
> class Person {
>     final String name
>     // marking this method as 'protected' will fix the issue
>     private Person(String name) {
>         this.name = name
>     }
>     static void load(String name, Handler<Person> handler) {
>         Thread.start {
>             Person person = new Person(name)
>             handler.handle(person)
>         }
>     }
> }
> Person.load('John') { Person p ->
>     println p.name
> }
> {code}
> Error:
> {quote}
> Test.groovy: 20: Cannot call private constructor for Person from class 
> Person$_load_closure1 @ line 20, column 20.
>                       Person person = new Person(name)
>                       ^
> 1 error
> {quote}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to