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 2021/09/13 20:02:05 UTC

[groovy] branch master updated: GROOVY-10229: LUB: retain "? extends T" -- do not reduce to "?"

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9ababe1  GROOVY-10229: LUB: retain "? extends T" -- do not reduce to "?"
9ababe1 is described below

commit 9ababe1ea947a42562d60e1af60cc2e5dbca61c7
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Sep 13 15:01:52 2021 -0500

    GROOVY-10229: LUB: retain "? extends T" -- do not reduce to "?"
---
 .../java/org/codehaus/groovy/ast/tools/WideningCategories.java    | 8 ++++++--
 src/test/gls/generics/GenericsBytecodeTest.groovy                 | 3 +--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
index 939ad6d..bdd232f 100644
--- a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
+++ b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
@@ -270,17 +270,21 @@ public class WideningCategories {
         }
         int n = agt.length; GenericsType[] lubGTs = new GenericsType[n];
         for (int i = 0; i < n; i += 1) {
+            if (agt[i].toString().equals(bgt[i].toString())) {
+                lubGTs[i] = agt[i];
+                continue;
+            }
             ClassNode t1 = agt[i].getType();
             ClassNode t2 = bgt[i].getType();
             ClassNode basicType;
             if (areEqualWithGenerics(t1, isPrimitiveType(a)?getWrapper(a):a) && areEqualWithGenerics(t2, isPrimitiveType(b)?getWrapper(b):b)) {
-                // we are facing a self referencing type !
+                // we are facing a self-referencing type !
                 basicType = fallback;
             } else {
                 basicType = lowestUpperBound(t1, t2);
             }
             if (t1.equals(t2)) {
-                lubGTs[i] = new GenericsType(basicType);
+                lubGTs[i] = basicType.asGenericsType();
             } else {
                 lubGTs[i] = GenericsUtils.buildWildcardType(basicType);
             }
diff --git a/src/test/gls/generics/GenericsBytecodeTest.groovy b/src/test/gls/generics/GenericsBytecodeTest.groovy
index 9d86d97..bc4a076 100644
--- a/src/test/gls/generics/GenericsBytecodeTest.groovy
+++ b/src/test/gls/generics/GenericsBytecodeTest.groovy
@@ -215,7 +215,7 @@ class GenericsBytecodeTest extends GenericsTestBase {
                 Map<String,List<?>> b() {
                     def c = {
                         [
-                            a()
+                            a(), a()
                         ]
                     }
                     return null
@@ -235,7 +235,6 @@ class GenericsBytecodeTest extends GenericsTestBase {
                class B<T> {
                    private T owner;
                    Class<T> getOwnerClass(){}
-
             }
         """
         assert signatures == [