groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: GROOVY-8313: NullPointerException in TypeResolver when using generic array return type
Date Mon, 16 Oct 2017 23:56:34 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 25e06fbde -> 5a7e04e86


GROOVY-8313: NullPointerException in TypeResolver when using generic array return type


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5a7e04e8
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5a7e04e8
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5a7e04e8

Branch: refs/heads/master
Commit: 5a7e04e86341624324e483ffcb1dcf77259fb8e8
Parents: 25e06fb
Author: paulk <paulk@asert.com.au>
Authored: Tue Oct 17 09:56:24 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Tue Oct 17 09:56:24 2017 +1000

----------------------------------------------------------------------
 .../org/codehaus/groovy/classgen/Verifier.java  |  2 +-
 src/test/groovy/bugs/Groovy8313Bug.groovy       | 38 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5a7e04e8/src/main/org/codehaus/groovy/classgen/Verifier.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/Verifier.java b/src/main/org/codehaus/groovy/classgen/Verifier.java
index 20fe156..da26a1b 100644
--- a/src/main/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/org/codehaus/groovy/classgen/Verifier.java
@@ -1354,7 +1354,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
         MethodNode newMethod = new MethodNode(
                 oldMethod.getName(),
                 overridingMethod.getModifiers() | ACC_SYNTHETIC | ACC_BRIDGE,
-                oldMethod.getReturnType().getPlainNodeReference(),
+                cleanType(oldMethod.getReturnType()),
                 cleanParameters(oldMethod.getParameters()),
                 oldMethod.getExceptions(),
                 null

http://git-wip-us.apache.org/repos/asf/groovy/blob/5a7e04e8/src/test/groovy/bugs/Groovy8313Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8313Bug.groovy b/src/test/groovy/bugs/Groovy8313Bug.groovy
new file mode 100644
index 0000000..aa3b43f
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8313Bug.groovy
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.bugs
+
+class Groovy8313Bug extends GroovyTestCase {
+    void testCorrectBridgeMethodForGenericArrayReturnType() {
+        assertScript '''
+            interface HasItems<T> {
+                T[] getItems()
+            }
+
+            class Things implements HasItems<String> {
+                final String[] items
+                Things(String... items) {
+                    this.items = items
+                }
+            }
+
+            assert new Things('item1').items.size() == 1
+        '''
+    }
+}


Mime
View raw message