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


##########
grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/reflect/AstUtils.groovy:
##########
@@ -248,8 +248,20 @@ class AstUtils {
         VariableScopeVisitor scopeVisitor = new VariableScopeVisitor(source)
         if (methodNode == null) {
             scopeVisitor.visitClass(classNode)
+            return
+        }
+        scopeVisitor.prepareVisit(classNode)
+        if (methodNode.exceptions == null) {
+            // Groovy 5's VariableScopeVisitor reads the method's exceptions 
array without a null check, and AST
+            // transforms routinely create methods via 
ClassNode.addMethod(..., null, ...). MethodNode.exceptions is
+            // final, so recompute scopes on a proxy that shares the same 
parameters and code but carries an empty
+            // exceptions array, then copy the computed scope back onto the 
real method.
+            MethodNode proxy = new MethodNode(methodNode.name, 
methodNode.modifiers, methodNode.returnType,

Review Comment:
   Isn't the real fix to populate the exceptions then? 



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