You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2022/09/11 20:11:12 UTC

[groovy] branch GROOVY_3_0_X updated: GROOVY-8034: apply context type arguments to non-static method parameter

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new 77f973682b GROOVY-8034: apply context type arguments to non-static method parameter
77f973682b is described below

commit 77f973682b2c70bf80c1fcef7e16f43def4bf88c
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Sep 11 14:37:54 2022 -0500

    GROOVY-8034: apply context type arguments to non-static method parameter
---
 .../codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index c8cdebe597..e2a0263d49 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1387,9 +1387,12 @@ public abstract class StaticTypeCheckingSupport {
     }
 
     static void addMethodLevelDeclaredGenerics(final MethodNode method, final Map<GenericsTypeName, GenericsType> resolvedPlaceholders) {
-        ClassNode dummy = OBJECT_TYPE.getPlainNodeReference();
-        dummy.setGenericsTypes(method.getGenericsTypes());
-        GenericsUtils.extractPlaceholders(dummy, resolvedPlaceholders);
+        GenericsType[] generics = method.getGenericsTypes();
+        if (!method.isStatic() && !resolvedPlaceholders.isEmpty()) {
+            // GROOVY-8034: non-static method may use class generics
+            generics = applyGenericsContext(resolvedPlaceholders, generics);
+        }
+        GenericsUtils.extractPlaceholders(GenericsUtils.makeClassSafe0(OBJECT_TYPE, generics), resolvedPlaceholders);
     }
 
     protected static boolean typeCheckMethodsWithGenerics(final ClassNode receiver, final ClassNode[] argumentTypes, final MethodNode candidateMethod) {