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 17:50:43 UTC

[groovy] branch GROOVY_3_0_X updated: GROOVY-10229: add test case

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 8d8bbff  GROOVY-10229: add test case
8d8bbff is described below

commit 8d8bbffa4a278bc63ed21d05aea300b1138c1e81
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Sep 13 12:07:11 2021 -0500

    GROOVY-10229: add test case
---
 src/test/gls/generics/GenericsBytecodeTest.groovy | 74 +++++++++++++++--------
 1 file changed, 49 insertions(+), 25 deletions(-)

diff --git a/src/test/gls/generics/GenericsBytecodeTest.groovy b/src/test/gls/generics/GenericsBytecodeTest.groovy
index 897149c..9d86d97 100644
--- a/src/test/gls/generics/GenericsBytecodeTest.groovy
+++ b/src/test/gls/generics/GenericsBytecodeTest.groovy
@@ -160,8 +160,8 @@ class GenericsBytecodeTest extends GenericsTestBase {
 
     void testMultipleBounds() {
         createClassInfo """
-            class Pair<    A extends Comparable<A> & Cloneable , 
-                        B extends Cloneable & Comparable<B> > 
+            class Pair<    A extends Comparable<A> & Cloneable ,
+                        B extends Cloneable & Comparable<B> >
             {
                 A foo(){}
                 B bar(){}
@@ -174,34 +174,59 @@ class GenericsBytecodeTest extends GenericsTestBase {
         ]
     }
 
-    void testWildCard() {
-        createClassInfo """
-            class B {
-                private Collection<?> f1 
-                private List<? extends Number> f2 
-                private Comparator<? super String> f3 
-                private Map<String,?> f4  
+    void testWildcard1() {
+        createClassInfo '''
+            class C {
+                private Collection<?> f1
+                private List<? extends Number> f2
+                private Comparator<? super String> f3
+                private Map<String,?> f4
             }
-        """
+        '''
         assert signatures == [
-                f1: "Ljava/util/Collection<*>;",
-                f2: "Ljava/util/List<+Ljava/lang/Number;>;",
-                f3: "Ljava/util/Comparator<-Ljava/lang/String;>;",
-                f4: "Ljava/util/Map<Ljava/lang/String;*>;"
+            f1: 'Ljava/util/Collection<*>;',
+            f2: 'Ljava/util/List<+Ljava/lang/Number;>;',
+            f3: 'Ljava/util/Comparator<-Ljava/lang/String;>;',
+            f4: 'Ljava/util/Map<Ljava/lang/String;*>;'
         ]
     }
 
-    void testwildcardWithBound() {
-        createClassInfo """
-            class Something<T extends Number> {
+    void testWildcard2() {
+        createClassInfo '''
+            class C<T extends Number> {
                 List<? super T> dependency
             }
-        """
+        '''
         assert signatures == [
-                "class"                           : "<T:Ljava/lang/Number;>Ljava/lang/Object;Lgroovy/lang/GroovyObject;",
-                dependency                        : "Ljava/util/List<-TT;>;",
-                "setDependency(Ljava/util/List;)V": "(Ljava/util/List<-TT;>;)V",
-                "getDependency()Ljava/util/List;" : "()Ljava/util/List<-TT;>;",
+            class                             : '<T:Ljava/lang/Number;>Ljava/lang/Object;Lgroovy/lang/GroovyObject;',
+            dependency                        : 'Ljava/util/List<-TT;>;',
+            'getDependency()Ljava/util/List;' : '()Ljava/util/List<-TT;>;',
+            'setDependency(Ljava/util/List;)V': '(Ljava/util/List<-TT;>;)V'
+        ]
+    }
+
+    // GROOVY-10229
+    void testWildcard3() {
+        createClassInfo '''
+            @groovy.transform.CompileStatic
+            class C {
+                Map<String,?> a() {
+                }
+                Map<String,List<?>> b() {
+                    def c = {
+                        [
+                            a()
+                        ]
+                    }
+                    return null
+                }
+            }
+        '''
+        assert signatures == [
+            'a()Ljava/util/Map;'                        : '()Ljava/util/Map<Ljava/lang/String;*>;',
+            'b()Ljava/util/Map;'                        : '()Ljava/util/Map<Ljava/lang/String;Ljava/util/List<*>;>;',
+            'doCall()Ljava/util/List;'                  : '()Ljava/util/List<Ljava/util/Map<Ljava/lang/String;+Ljava/lang/Object;>;>;',
+            'doCall(Ljava/lang/Object;)Ljava/util/List;': '(Ljava/lang/Object;)Ljava/util/List<Ljava/util/Map<Ljava/lang/String;+Ljava/lang/Object;>;>;'
         ]
     }
 
@@ -210,8 +235,8 @@ class GenericsBytecodeTest extends GenericsTestBase {
                class B<T> {
                    private T owner;
                    Class<T> getOwnerClass(){}
-   
-            } 
+
+            }
         """
         assert signatures == [
                 "class"                           : "<T:Ljava/lang/Object;>Ljava/lang/Object;Lgroovy/lang/GroovyObject;",
@@ -227,7 +252,6 @@ class GenericsBytecodeTest extends GenericsTestBase {
         assert signatures == ["class": "<T:Ljava/lang/Object;>Ljava/lang/Object;"]
     }
 
-
     void testTypeParamAsBound() {
         createClassInfo """
             class Box<A> {