[
https://issues.apache.org/jira/browse/GROOVY-11694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956753#comment-17956753
]
ASF GitHub Bot commented on GROOVY-11694:
-----------------------------------------
Copilot commented on code in PR #2251:
URL: https://github.com/apache/groovy/pull/2251#discussion_r2134427507
##########
src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java:
##########
@@ -304,6 +299,9 @@ protected boolean writeDirectMethodCall(final MethodNode
target, final boolean i
}
ClassNode receiverType = receiver == null ? ClassHelper.OBJECT_TYPE :
controller.getTypeChooser().resolveType(receiver, controller.getThisType());
+ if
(StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType(receiverType)
&& !ClassHelper.isClassType(declaringClass)) {
+ receiverType = receiverType.getGenericsTypes()[0].getType(); //
GROOVY-11694
Review Comment:
Consider adding a check to ensure that receiverType.getGenericsTypes() is
not null and contains at least one element before accessing index 0 to prevent
potential NullPointerExceptions.
```suggestion
if (receiverType.getGenericsTypes() != null &&
receiverType.getGenericsTypes().length > 0) {
receiverType = receiverType.getGenericsTypes()[0].getType();
// GROOVY-11694
} else {
// Handle the case where generics types are null or empty
receiverType = ClassHelper.OBJECT_TYPE; // Default to Object
type
}
```
> SC: implicit-this call to static method of super class from another package
> ---------------------------------------------------------------------------
>
> Key: GROOVY-11694
> URL: https://issues.apache.org/jira/browse/GROOVY-11694
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 5.0.0-beta-1
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Major
>
> Consider the following:
> {code:groovy}
> package p
> abstract class A {
> protected static pm() {
> }
> }
> {code}
> {code:groovy}
> package q
> @groovy.transform.CompileStatic
> class C extends p.A {
> void test() {
> pm()
> }
> }
> {code}
> Compiler emits error: "Cannot access method: pm() of class: p.A"
--
This message was sent by Atlassian Jira
(v8.20.10#820010)