jamesfredley commented on code in PR #15557:
URL: https://github.com/apache/grails-core/pull/15557#discussion_r3343112395


##########
grails-test-suite-uber/src/test/groovy/grails/compiler/DomainClassWithInnerClassUsingStaticCompilationSpec.groovy:
##########
@@ -55,14 +55,14 @@ class SomeClass implements Validateable {
     static boolean namedQueriesClosureCalled = false
 
     static constraints = {
-        constraintsClosureCalled = true
+        SomeClass.constraintsClosureCalled = true

Review Comment:
   Documented in the upgrade guide (`upgrading80x.adoc`, new section 24.1): 
under Groovy 5 with static compilation, assigning to a static field from inside 
a static closure (`static constraints = { ... }`) no longer resolves an 
unqualified field name to the enclosing class - it must be qualified 
(`SomeClass.constraintsClosureCalled = true`), which is exactly the change in 
this spec.



##########
grails-validation/src/main/groovy/grails/validation/Validateable.groovy:
##########
@@ -279,4 +280,27 @@ trait Validateable {
     static boolean defaultNullable() {
         false
     }
+
+    /**
+     * Resolves defaultNullable() via reflection to preserve trait 
static-method override semantics (Groovy 5).
+     * Reproducer: 
https://github.com/jamesfredley/groovy-trait-static-method-override-bug

Review Comment:
   Added the ticket reference - the comment now points at GROOVY-11985 (the 
`TraitReceiverTransformer` static-override issue) and explains that the 
in-trait `defaultNullable()` call is rewritten to a direct trait-helper static 
call under Groovy 5, losing the implementing class's override, so reflection is 
used to honour it.



##########
grails-views-core/src/main/groovy/grails/views/mvc/renderer/DefaultViewRenderer.groovy:
##########
@@ -118,7 +118,7 @@ abstract class DefaultViewRenderer<T> extends 
DefaultHtmlRenderer<T> {
         }
 
         if (view != null) {
-            Map<String, ?> model
+            Map<String, Object> model

Review Comment:
   Groovy 5's STC got stricter about assigning to a wildcard-typed local: 
`Map<String, ?> model` followed by `model = map` (a raw/`Map` value) no longer 
type-checks, so the variable is declared `Map<String, Object>`. It is purely a 
local type-declaration change with no runtime effect. @paulk-asert is the 
tighter handling of `?`-typed assignment targets intended in Groovy 5?



-- 
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]

Reply via email to