Copilot commented on code in PR #2764:
URL: https://github.com/apache/groovy/pull/2764#discussion_r3709522591
##########
src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java:
##########
@@ -149,6 +151,17 @@ public void visitConstructor(final ConstructorNode node) {
}
}
+ /**
+ * Tests for one of the classes generated for a trait, i.e. the helper, the
+ * field helper or the static field helper. Classes declared within a trait
+ * are not included.
+ */
+ private static boolean isTraitHelper(final ClassNode node) {
+ ClassNode outerClass = node.getOuterClass();
+ return isTrait(outerClass) && (node.getModifiers() & ACC_SYNTHETIC) != 0
+ && node.getName().startsWith(outerClass.getName() + "$Trait$");
+ }
Review Comment:
`isTraitHelper` currently identifies helper classes using
`startsWith(outerClass.getName() + "$Trait$")`. This can incorrectly classify
user-declared inner classes whose *simple* name begins with `Trait$...` (e.g.
`static class Trait$Foo {}` inside a trait), causing this visitor to skip them
and potentially reintroduce runtime issues. Prefer matching the exact helper
class names/suffixes (Helper/FieldHelper/StaticFieldHelper) to avoid false
positives.
--
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]