Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.20
-
None
-
Java 21, gradle 8.5, MacOS
Description
Hi,
The code below works fine with 3.0.19 but after upgrading to 3.0.20 it doesn't compile anymore:
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 } }
My build.gradle
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 }
A simple "gradle compileGroovy" should reproduce the issue:
/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 ^
Attachments
Issue Links
- is related to
-
GROOVY-11257 [STC] Cannot detect the type of Optional in some cases
- Closed