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:55:59 UTC

[groovy] branch GROOVY_2_5_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_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


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

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

    GROOVY-10756: STC: upper bound for unresolved placeholder
---
 .../groovy/transform/stc/StaticTypeCheckingSupport.java        |  4 ++--
 .../transform/stc/ClosureParamTypeInferenceSTCTest.groovy      | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 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 7b9efe147b..909103cfb0 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1383,8 +1383,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
             } else {
                 GenericsType[] gts = type.getGenericsTypes();
                 if (gts != null) {  final int n = gts.length;
diff --git a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
index 619c3c2232..2246d15f42 100644
--- a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
@@ -1463,13 +1463,19 @@ class ClosureParamTypeInferenceSTCTest extends StaticTypeCheckingTestCase {
 
     static class Java10756 {
         static <T extends File> Collection<T> getFiles() {
+            []
         }
     }
 
     void testGroovy10756() {
         assertScript """import ${Java10756.name.replace('$','.')}
-            Java10756.files?.collect { it.name }
-            //                         ^^ File
+            Java10756.files.collect { it.name }
+            //                        ^^ File
+        """
+
+        assertScript """import ${Java10756.name.replace('$','.')}
+            def file = Java10756.files[0]
+            file?.name
         """
     }
 }