You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "codeconsole (via GitHub)" <gi...@apache.org> on 2026/06/05 18:28:14 UTC
[PR] Register CriteriaTypeCheckingExtension in @GrailsCompileStatic and cover createCriteria().{} closures [grails-core]
codeconsole opened a new pull request, #15719:
URL: https://github.com/apache/grails-core/pull/15719
## What
`CriteriaTypeCheckingExtension` exists in grails-core but is **not registered** in `@GrailsCompileStatic`'s extension list, and it only recognizes the `Domain.withCriteria { … }` form (closure as the direct argument). The far more common `Domain.createCriteria().list/get/count { … }` chain — where the closure is the argument to the *terminal* call on the builder — is never entered, so its `eq`/`order`/`projections`/etc. calls fail static type checking.
The result: every `createCriteria()…{}` site under static compilation has to be marked `@CompileDynamic`, even when the only dynamic part is the criteria builder DSL.
## Change
1. Extend `isCriteriaCall` to also open a criteria scope when the call is a terminal (`list`, `listDistinct`, `get`, `count`, `scroll`) chained directly on `Domain.createCriteria()`.
2. Add `org.grails.compiler.CriteriaTypeCheckingExtension` to the `@CompileStatic(extensions=[…])` list on `@GrailsCompileStatic`.
With both in place, criteria-builder closures type-check under `@GrailsCompileStatic` and no longer require `@CompileDynamic`.
## Scope / limits
The extension makes the *direct children* of the criteria closure dynamic. Deeply nested builder closures (e.g. `projections { property '…' }`) and post-processing that indexes the projection result (`withCriteria { … }[0]`) still need `@CompileDynamic` — those are out of scope here.
## Testing
Verified against a multi-module Grails 7.2 app: `createCriteria().list(params){ eq(...) }` and `createCriteria().get { ilike(...); maxResults(1) }` compile cleanly under `@GrailsCompileStatic` with the extension registered, where they previously required `@CompileDynamic`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Register CriteriaTypeCheckingExtension in @GrailsCompileStatic and cover createCriteria().{} closures [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole closed pull request #15719: Register CriteriaTypeCheckingExtension in @GrailsCompileStatic and cover createCriteria().<terminal>{} closures
URL: https://github.com/apache/grails-core/pull/15719
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Register CriteriaTypeCheckingExtension in @GrailsCompileStatic and cover createCriteria().{} closures [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15719:
URL: https://github.com/apache/grails-core/pull/15719#issuecomment-4634463284
Superseded by the 8.0.x-based PR — 7.2.x is no longer accepting new features.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org