bito-code-review[bot] commented on PR #15733:
URL: https://github.com/apache/grails-core/pull/15733#issuecomment-4699010323
<!-- Bito Reply -->
The current implementation in `ControllerTagLibraryInvoker.groovy` provides
a statically-resolvable `message(Map)` method to allow `message` tag calls to
resolve under `@CompileStatic` in controllers, avoiding dynamic dispatch.
Regarding the suggestion to use a registry or a static solution that defers
to dynamic dispatch:
* **Registry Solution:** A registry-based approach would decouple the tag
invocation logic from the trait, potentially allowing for more flexible
registration of statically-resolvable tags beyond just `message`.
* **Static-to-Dynamic Dispatch:** A static method that internally calls the
existing dynamic dispatch mechanism (similar to what is currently implemented)
is already being used to ensure identical behavior. If the goal is to avoid
duplicating this logic across multiple traits, moving the implementation to a
shared utility or a registry would be the appropriate architectural step.
Since the current implementation is already a static method that defers to
the dynamic `TagOutput.captureTagOutput` machinery, it effectively achieves the
goal of static compilation support while maintaining identical runtime behavior.
**grails-gsp/grails-web-taglib/src/main/groovy/grails/artefact/gsp/ControllerTagLibraryInvoker.groovy**
```
Object message(Map attrs) {
TagLibraryLookup lookup = getTagLibraryLookup()
if (lookup) {
String namespace = getTaglibNamespace()
GroovyObject tagLibrary = lookup.lookupTagLibrary(namespace,
'message')
if (tagLibrary == null && namespace !=
TagOutput.DEFAULT_NAMESPACE) {
namespace = TagOutput.DEFAULT_NAMESPACE
tagLibrary = lookup.lookupTagLibrary(namespace, 'message')
}
if (tagLibrary != null) {
return TagOutput.captureTagOutput(lookup, namespace,
'message', attrs, null,
OutputContextLookupHelper.lookupOutputContext())
}
}
throw new MissingMethodException('message', this.getClass(), [attrs]
as Object[])
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]