groovy git commit: GROOVY-8156: Compile error when ListenerList annotation exists (closes #524)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

groovy git commit: GROOVY-8156: Compile error when ListenerList annotation exists (closes #524)

jwagenleitner-2
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X 9a4657646 -> 466c96878


GROOVY-8156: Compile error when ListenerList annotation exists (closes #524)


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 466c96878527a8dede378a81ef5ebeb5088177f8
Parents: 9a46576
Author: John Wagenleitner <[hidden email]>
Authored: Fri Apr 14 13:33:59 2017 -0700
Committer: John Wagenleitner <[hidden email]>
Committed: Wed Apr 19 21:01:09 2017 -0700

----------------------------------------------------------------------
 .../beans/ListenerListASTTransformation.groovy  |  3 +--
 .../groovy/beans/ListenerListASTTest.groovy     | 27 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/466c9687/src/main/groovy/beans/ListenerListASTTransformation.groovy
----------------------------------------------------------------------
diff --git a/src/main/groovy/beans/ListenerListASTTransformation.groovy b/src/main/groovy/beans/ListenerListASTTransformation.groovy
index 4591346..2e8b664 100644
--- a/src/main/groovy/beans/ListenerListASTTransformation.groovy
+++ b/src/main/groovy/beans/ListenerListASTTransformation.groovy
@@ -18,7 +18,6 @@
  */
 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
@@ -353,7 +352,7 @@ class ListenerListASTTransformation implements ASTTransformation, Opcodes {
 
         def params = method.parameters.collect {
             def paramType = ClassHelper.getWrapper(it.type)
-            def cn = GenericsUtils.makeClassSafe(paramType.typeClass)
+            def cn = paramType.plainNodeReference
             cn.setRedirect(paramType)
             new Parameter(cn, it.name)
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/466c9687/src/test/groovy/beans/ListenerListASTTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/beans/ListenerListASTTest.groovy b/src/test/groovy/beans/ListenerListASTTest.groovy
index 3952231..dae62aa 100644
--- a/src/test/groovy/beans/ListenerListASTTest.groovy
+++ b/src/test/groovy/beans/ListenerListASTTest.groovy
@@ -384,4 +384,31 @@ class ListenerListASTTest extends GroovyTestCase {
                 assert C.class.getMethod('getObjects')
             """)
         }
+
+    // GROOVY-8156
+    void testListenerListWithEventClassInSameCompilationUnit() {
+        assertScript '''
+            class Event {}
+
+            class EventListener {
+                Event event
+                void doSomething(Event e) {
+                    event = e
+                }
+            }
+
+            class EventHandler {
+                @groovy.beans.ListenerList
+                List<EventListener> listeners
+            }
+
+            def listener = new EventListener()
+            def eh = new EventHandler()
+            eh.addEventListener(listener)
+            def testEvent = new Event()
+            eh.fireDoSomething(testEvent)
+
+            assert listener.event.is(testEvent)
+        '''
+    }
 }