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/20 17:12:12 UTC

[groovy] branch GROOVY_4_0_X updated: GROOVY-10756: STC: upper bound for unresolved placeholder

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

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


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new ced9675d0a GROOVY-10756: STC: upper bound for unresolved placeholder
ced9675d0a is described below

commit ced9675d0a79e213d6d3ac2e9bcd01e2366d671d
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Sep 20 09:20:01 2022 -0500

    GROOVY-10756: STC: upper bound for unresolved placeholder
---
 .../org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java | 4 ++--
 .../groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy     | 5 +++++
 2 files changed, 7 insertions(+), 2 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 8faa4b5c45..9718f233a9 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1368,8 +1368,8 @@ public abstract class StaticTypeCheckingSupport {
             if (gt != null) {
                 return gt.getType();
             }
-            ClassNode cn = type.redirect();
-            return cn != type ? cn : OBJECT_TYPE;
+            ClassNode cn = extractType(type.asGenericsType()); // GROOVY-10756
+            return cn != type ? cn : OBJECT_TYPE; // do not return placeholder
         }
 
         GenericsType[] gts = type.getGenericsTypes();
diff --git a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
index f7e033f8fa..c05b254241 100644
--- a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
@@ -1590,5 +1590,10 @@ class ClosureParamTypeInferenceSTCTest extends StaticTypeCheckingTestCase {
             Java10756.files?.collect { it.name }
             //                         ^^ File
         """
+
+        assertScript """import ${Java10756.name.replace('$','.')}
+            def file = Java10756.files?[0]
+            file?.name
+        """
     }
 }