[ https://issues.apache.org/jira/browse/GROOVY-11266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles closed GROOVY-11266. -------------------------------- Fix Version/s: 3.0.21 Resolution: Fixed https://github.com/apache/groovy/commit/f72ec8ba53b0b645a1044c033752f903c9ce84d3 > Static Compilation fails when using generics (no such property) > --------------------------------------------------------------- > > Key: GROOVY-11266 > URL: https://issues.apache.org/jira/browse/GROOVY-11266 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker > Affects Versions: 3.0.20 > Environment: Java 21, gradle 8.5, MacOS > Reporter: Rodolfo Yanke > Assignee: Eric Milles > Priority: Major > Fix For: 3.0.21 > > > Hi, > The code below works fine with 3.0.19 but after upgrading to 3.0.20 it > doesn't compile anymore: > {code:java} > import groovy.transform.CompileStatic > import org.springframework.data.domain.Pageable > import org.springframework.data.mongodb.repository.MongoRepository > @CompileStatic > class GalleryItem { > String someProperty > } > @CompileStatic > interface GalleryItemRepository extends MongoRepository<GalleryItem, String> { > } > @CompileStatic > static void main(String[] args) { > GalleryItemRepository repository = null //no implementation for the sake > of simplicity > def page = repository.findAll(Pageable.ofSize(1)) > page.content.each { > it.someProperty //[Static type checking] - No such property: > someProperty for class: java.lang.Object > } > } {code} > My build.gradle > {code:java} > plugins { > id 'groovy' > } > group = 'org.example' > version = '1.0-SNAPSHOT' > repositories { > mavenCentral() > } > dependencies { > //works fine with 3.0.19 > implementation 'org.codehaus.groovy:groovy-all:3.0.20' > implementation 'org.springframework.data:spring-data-mongodb:3.4.18' > } > compileJava { > sourceCompatibility = JavaVersion.VERSION_21 > targetCompatibility = JavaVersion.VERSION_21 > } > compileGroovy { > groovyOptions.optimizationOptions.indy = true > }{code} > A simple "gradle compileGroovy" should reproduce the issue: > {code:java} > /Projects/groovytest/src/main/groovy/Main.groovy: 20: [Static type checking] > - No such property: someProperty for class: java.lang.Object > @ line 20, column 9. > it.someProperty //[Static type checking] - No such property: > someProperty for class: java.lang.Object > ^ {code} > > -- This message was sent by Atlassian Jira (v8.20.10#820010)