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 2020/07/23 14:17:06 UTC
[jira] [Closed] (GROOVY-9422) @CompileStatic non-static inner class
instantiation in closure
[ https://issues.apache.org/jira/browse/GROOVY-9422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-9422.
-----------------------------
> @CompileStatic non-static inner class instantiation in closure
> --------------------------------------------------------------
>
> Key: GROOVY-9422
> URL: https://issues.apache.org/jira/browse/GROOVY-9422
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.3.4, 2.4.0, 2.5.0, 3.0.0
> Reporter: Aleksey
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-alpha-1, 3.0.5, 2.5.13
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> 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)