Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Similarly to GROOVY-5531, I'm facing another problem with the same sample.
Static type checking the class is fine, but I get a compilation error coming from StaticTypesCallSiteWriter#makeGetPropertySite() when trying to access the closure's parameter property.
The offending sample:
import groovy.transform.CompileStatic class User { String login } interface Row<R> { R getKey() } class RowImpl<R> implements Row<R> { R getKey() { null } } @CompileStatic class UserRepository implements Serializable { Collection<User> getUsers() { def rows = [new RowImpl<String>()] return rows.collect { Row<String> row -> new User(login: row.key) } } } def rep = new UserRepository() rep.getUsers()
Error I get:
Access to java.lang.Object#key is forbidden at line: 21, column: 29
Attachments
Issue Links
- relates to
-
GROOVY-5531 Problem accessing closure parameter inside named arg constructor values inside a closure in a @CompileStatic class
- Closed