You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "A. Lepe (Jira)" <ji...@apache.org> on 2023/05/26 07:07:00 UTC
[jira] [Created] (GROOVY-11072) Unable to compile: Expected type for closure parameter
A. Lepe created GROOVY-11072:
--------------------------------
Summary: Unable to compile: Expected type for closure parameter
Key: GROOVY-11072
URL: https://issues.apache.org/jira/browse/GROOVY-11072
Project: Groovy
Issue Type: Bug
Components: Compiler
Affects Versions: 3.0.17, 3.0.16, 3.0.15, 3.0.14, 3.0.13, 3.0.12, 4.x
Environment: Ubuntu 22.04
Java 11
Reporter: A. Lepe
This code is unable to compile, throwing the exception:
{code:java}
Main.groovy: 15: 22: [Static type checking] - Expected type java.util.List<T> for closure parameter: list
@ line 22, column 17.
List<String> list ->
^
Main.groovy: 17: [Static type checking] - Expected type java.lang.Object for closure parameter: tm
@ line 17, column 21.
TestModel tm ->
^
Main.groovy: 18: [Static type checking] - No such property: id for class: java.lang.Object
@ line 18, column 33.
println(tm.id)
^{code}
Code:
{code:java}
@CompileStatic
class Main {
static void main(String[] args) {
TestTable table = new TestTable()
table.getAll({
List<TestModel> list ->
list.each {
TestModel tm ->
println(tm.id)
}
})
}
}{code}
This is a simplified version of my code which worked fine in 3.0.11, it failed first on 3.0.12 including 4.x.
I have prepared a git project with the minimum code at:
[https://gitlab.com/intellisrc/groovy-compile-error2]
In _build.gradle_ you can change between 3.0.11 and 4.0.12 versions
--
This message was sent by Atlassian Jira
(v8.20.10#820010)