codeconsole commented on code in PR #16401:
URL: https://github.com/apache/grails-core/pull/16401#discussion_r4101974651
##########
grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java:
##########
@@ -774,11 +774,13 @@ private static boolean
implementsInterfaceInternal(ClassNode[] interfaces, Strin
if (anInterface.getName().equals(interfaceName)) {
return true;
}
+ // Every interface is searched. Returning the first one's
super-interfaces' answer missed
+ // an interface listed after one that has super-interfaces of its
own.
ClassNode[] childInterfaces = anInterface.getInterfaces();
- if (childInterfaces != null && childInterfaces.length > 0) {
- return implementsInterfaceInternal(childInterfaces,
interfaceName);
+ if (childInterfaces != null && childInterfaces.length > 0 &&
+ implementsInterfaceInternal(childInterfaces,
interfaceName)) {
+ return true;
}
Review Comment:
Done in 398c1230d3: `implementsInterface` now returns
`classNode.implementsInterface(ClassHelper.make(interfaceName))`, and
`implementsInterfaceInternal` is gone. I checked it against Groovy 5.1.0's
`ClassNode` (superclass walk, `declaresInterface` over every super-interface,
equality by name). The `GrailsASTUtilsSpec` cases pass, and with the dependent
modules' `compileGroovy` forced to re-run, every generated `grails.factories`
is still byte-identical to 8.0.x.
##########
grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/reflect/AstUtils.groovy:
##########
@@ -820,11 +820,15 @@ class AstUtils {
if (anInterface.getName().equals(interfaceName)) {
return anInterface
}
+ // Every interface is searched. Returning the first one's
super-interfaces' answer missed
+ // an interface listed after one that has super-interfaces of its
own.
ClassNode[] childInterfaces = anInterface.getInterfaces()
if (childInterfaces != null && childInterfaces.length > 0) {
- return implementsInterfaceInternal(childInterfaces,
interfaceName)
+ ClassNode found = implementsInterfaceInternal(childInterfaces,
interfaceName)
+ if (found != null) {
+ return found
+ }
}
Review Comment:
Applied in 398c1230d3: the comment moved to the commit message and the
length check is dropped. `findInterface` keeps its own walk, since it returns
the interface node it finds, which `ClassNode#implementsInterface` doesn't give
back.
--
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]