Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.12, 3.0.13, 3.0.14, 3.0.15, 3.0.16, 3.0.17
-
Ubuntu 22.04
Java 11
Description
This code is unable to compile, throwing the exception:
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:
@CompileStatic class Main { static void main(String[] args) { TestTable table = new TestTable() table.getAll({ List<TestModel> list -> list.each { TestModel tm -> println(tm.id) } }) } }
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
Attachments
Issue Links
- is related to
-
GROOVY-11013 Fail to substitute type when having SAM type with generics
- Closed