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 2017/09/20 14:11:00 UTC

[jira] [Commented] (GROOVY-8325) @CompileStatic calls wrong newInstance method.

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

Paul King commented on GROOVY-8325:
-----------------------------------

Error message is:
{noformat}
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: Foo(Integer)
{noformat}
Using {{Foo.newInstance(123L)}} works fine.


> @CompileStatic calls wrong newInstance method.
> ----------------------------------------------
>
>                 Key: GROOVY-8325
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8325
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, Static compilation
>    Affects Versions: 2.4.10
>            Reporter: Xiaoguang WANG
>            Priority: Critical
>
> {code:java}
> import groovy.transform.CompileStatic
> class Foo {
>     static Foo newInstance(Long v) {
>         return new Foo()
>     }
> }
> @CompileStatic   //crash only caused by this CompileStatic
> class TestGroovy {
>     static void main(String ... args) {
>         def a = Foo.newInstance(123)  //when @CompileStatic, this calls DefaultGroovyMethods.newInstance
>         println a
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)