groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 02/02: GROOVY-7160: NoSuchMethodError for varargs when type parameter extends interface (closes #869)
Date Fri, 01 Feb 2019 06:52:39 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 406487017401b397a7818d402ff4c2d2fd74b327
Author: Paul King <paulk@asert.com.au>
AuthorDate: Thu Jan 31 20:25:30 2019 +1000

    GROOVY-7160: NoSuchMethodError for varargs when type parameter extends interface (closes
#869)
---
 .../groovy/ast/decompiled/MemberSignatureParser.java   |  5 ++++-
 .../classgen/asm/sc/BugsStaticCompileTest.groovy       | 18 +++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/MemberSignatureParser.java b/src/main/java/org/codehaus/groovy/ast/decompiled/MemberSignatureParser.java
index 436c02c..0cefbe2 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/MemberSignatureParser.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/MemberSignatureParser.java
@@ -145,7 +145,10 @@ class MemberSignatureParser {
     }
 
     private static ClassNode applyErasure(ClassNode genericType, ClassNode erasure) {
-        if (genericType.isGenericsPlaceHolder()) {
+        if (genericType.isArray() && erasure.isArray() && genericType.getComponentType().isGenericsPlaceHolder())
{
+            genericType.setRedirect(erasure);
+            genericType.getComponentType().setRedirect(erasure.getComponentType());
+        } else if (genericType.isGenericsPlaceHolder()) {
             genericType.setRedirect(erasure);
         }
         return genericType;
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy
index 032f899..062054b 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/BugsStaticCompileTest.groovy
@@ -1464,5 +1464,21 @@ println someInt
             assert Groovy7784.multiVarArgs() == 'foo-bar-baz1-baz2'
         '''
     }
-}
 
+    // GROOVY-7160
+    void testGenericsArrayPlaceholder() {
+        assertScript '''
+            import static java.nio.file.AccessMode.*
+
+            @groovy.transform.CompileStatic
+            class Dummy {
+                static main() {
+                    // more than 5 to match `of(E first, E[] rest)` variant
+                    EnumSet.of(READ, WRITE, EXECUTE, READ, WRITE, EXECUTE)
+                }
+            }
+
+            assert Dummy.main() == [READ, WRITE, EXECUTE].toSet()
+        '''
+    }
+}


Mime
View raw message