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:57:34 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 81a684bb7 -> 7fd8cede9


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/7fd8cede
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7fd8cede
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7fd8cede

Branch: refs/heads/GROOVY_2_6_X
Commit: 7fd8cede9d01e004e67cd97d835a9bf27a6fcb78
Parents: 81a684b
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:57:21 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/7fd8cede/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/7fd8cede/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