You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/07/06 21:21:00 UTC

[jira] [Assigned] (GROOVY-9422) @CompileStatic non-statin inner class instantiation in closure

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

Eric Milles reassigned GROOVY-9422:
-----------------------------------

    Assignee: Eric Milles

> @CompileStatic non-statin inner class instantiation in closure
> --------------------------------------------------------------
>
>                 Key: GROOVY-9422
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9422
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.1
>            Reporter: Aleksey
>            Assignee: Eric Milles
>            Priority: Major
>
> Script:
> {code:groovy}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Test {
>     final String test = 'test-'
>     List<String> test() {
>         ['val'].collect {String s ->
>             return new InnerTest(s).val
>         }
>     }
>     class InnerTest {
>         final String val
>         InnerTest(String val) {
>             this.val = test + val
>         }
>     }
> }
> println(new Test().test())
> {code}
> Result:
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> ideaGroovyConsole.groovy: 9: [Static type checking] - Cannot find matching method Test$InnerTest#<init>(groovy.lang.Closure <V extends java.lang.Object>, java.lang.String). Please check if the declared type is correct and if the method exists.
>  @ line 9, column 20.
>                return new InnerTest(s).val
>                       ^
> 1 error
> 	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
> 	at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:963)
> and so on...
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)