You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/04/07 13:30:56 UTC

[13/50] [abbrv] groovy git commit: GROOVY-8110: @ListenerList generated fireWhatever() method stops working (closes #510)

GROOVY-8110: @ListenerList generated fireWhatever() method stops working (closes #510)


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

Branch: refs/heads/parrot
Commit: 4f4aa73e52a01dd05c8d3bac45f6765f2c7d174d
Parents: d516944
Author: paulk <pa...@asert.com.au>
Authored: Thu Mar 9 17:59:15 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Mar 10 07:11:08 2017 +1000

----------------------------------------------------------------------
 .../beans/ListenerListASTTransformation.groovy  |  3 +-
 src/test/groovy/bugs/Groovy8110Bug.groovy       | 45 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/4f4aa73e/src/main/groovy/beans/ListenerListASTTransformation.groovy
----------------------------------------------------------------------
diff --git a/src/main/groovy/beans/ListenerListASTTransformation.groovy b/src/main/groovy/beans/ListenerListASTTransformation.groovy
index 1c191e7..4591346 100644
--- a/src/main/groovy/beans/ListenerListASTTransformation.groovy
+++ b/src/main/groovy/beans/ListenerListASTTransformation.groovy
@@ -18,6 +18,7 @@
  */
 package groovy.beans
 
+import org.codehaus.groovy.ast.tools.GenericsUtils
 import org.codehaus.groovy.control.CompilePhase
 import org.codehaus.groovy.control.SourceUnit
 import org.codehaus.groovy.control.messages.SyntaxErrorMessage
@@ -352,7 +353,7 @@ class ListenerListASTTransformation implements ASTTransformation, Opcodes {
 
         def params = method.parameters.collect {
             def paramType = ClassHelper.getWrapper(it.type)
-            def cn = ClassHelper.makeWithoutCaching(paramType.name)
+            def cn = GenericsUtils.makeClassSafe(paramType.typeClass)
             cn.setRedirect(paramType)
             new Parameter(cn, it.name)
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/4f4aa73e/src/test/groovy/bugs/Groovy8110Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8110Bug.groovy b/src/test/groovy/bugs/Groovy8110Bug.groovy
new file mode 100644
index 0000000..355d462
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8110Bug.groovy
@@ -0,0 +1,45 @@
+/*
+ *  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 Groovy8110Bug extends GroovyTestCase {
+    void testListenerListWithArrayParam() {
+        assertScript '''
+            import groovy.beans.ListenerList
+
+            interface MessageListener {
+                void messageReceived(byte[] msg)
+            }
+
+            class MessageProducer {
+                String log = ''
+                @ListenerList List<MessageListener> listeners
+
+                void produce(String msg) {
+                    fireMessageReceived(msg.getBytes())
+                }
+            }
+
+            producer = new MessageProducer()
+            producer.addMessageListener({ producer.log += it.toString() } as MessageListener)
+            producer.produce('Groovy')
+            assert producer.log == '[71, 114, 111, 111, 118, 121]'
+        '''
+    }
+}