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 2023/07/24 12:36:00 UTC
[jira] [Updated] (GROOVY-11135) Unable to compile: Expected type java.lang.Object for closure parameter
[ https://issues.apache.org/jira/browse/GROOVY-11135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-11135:
---------------------------------
Language: groovy
> Unable to compile: Expected type java.lang.Object for closure parameter
> -----------------------------------------------------------------------
>
> Key: GROOVY-11135
> URL: https://issues.apache.org/jira/browse/GROOVY-11135
> Project: Groovy
> Issue Type: Bug
> Components: Compiler, Static compilation
> Affects Versions: 3.0.18, 4.0.13
> Environment: Java : corretto-11.0.19
> Ubuntu 22.04
> Reporter: A. Lepe
> Assignee: Eric Milles
> Priority: Major
>
> The following code fails to compile:
> {code:java}
> @CompileStatic{code}
> {code:java}
> Map<Integer, String> files = new File("/").listFiles().toList().withIndex().collectEntries {
> File file, int index ->
> [(index) : file.name]
> }
> files.each {
> int i, String name ->
> println String.format("%d : %s", i, name)
> } {code}
> With the error:
> {noformat}
> > Task :compileGroovy
> startup failed:
> groovy-bugs/app/src/main/groovy/com/intellisrc/groovy/App.groovy: 9: [Static type checking] - Expected type java.lang.Object for closure parameter: file
> @ line 9, column 4.
> File file, int index ->
> ^{noformat}
> I have prepared a small project for testing:
> [https://gitlab.com/intellisrc/groovy-bugs/-/tree/with-index?ref_type=heads]
> Versions 3.0.17 , 4.0.12 and below seems to work as expected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)