You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by jd...@apache.org on 2026/09/30 14:47:47 UTC

(grails-core) 05/06: Document why DefaultGormDataFetcher.associations stays an unbounded wildcard

This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch refactor/graphql-fetcher
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 19c8f49d8b9d81d1873014c43ceb9e97356e7ddf
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Sun Aug 23 00:04:11 2026 -0500

    Document why DefaultGormDataFetcher.associations stays an unbounded wildcard
    
    IntelliJ flags Map<String, Association<?>> with "Type parameter '?' is
    not in its bound; should extend Property" since Association<T extends
    Property>. Writing the bound out explicitly
    (Association<? extends Property>) looks like the obvious fix, but
    Groovy's static type checker - unlike javac - treats the bounded and
    unbounded wildcard forms as distinct types, so
    initializeEntity()'s `this.associations = this.entityFetchOptions.associations`
    (which returns Map<String, Association<?>>) fails to compile against
    it. Keep the unbounded form and record why, the same treatment given
    to EntityFetchOptions' raw List<Selection> earlier in this cleanup.
    
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
 .../org/grails/gorm/graphql/fetcher/DefaultGormDataFetcher.groovy     | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/DefaultGormDataFetcher.groovy b/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/DefaultGormDataFetcher.groovy
index 4a0170ef36..58d0dcaf49 100644
--- a/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/DefaultGormDataFetcher.groovy
+++ b/grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/DefaultGormDataFetcher.groovy
@@ -48,6 +48,10 @@ import org.grails.gorm.graphql.entity.EntityFetchOptions
 @Slf4j
 abstract class DefaultGormDataFetcher<T> implements DataFetcher<T> {
 
+    // Association<?> (not Association<? extends Property>, its declared bound) to match the
+    // exact generic type EntityFetchOptions#getAssociations() returns - Groovy's static type
+    // checker treats the bounded and unbounded wildcard forms as distinct types, so writing out
+    // the bound here would make the assignment in initializeEntity() fail to compile.
     protected Map<String, Association<?>> associations = [:]
     protected PersistentEntity entity
     protected String propertyName