Sascha Frinken created GROOVY-8156:
--------------------------------------

             Summary: Compile error when ListenerList annotation exists
                 Key: GROOVY-8156
                 URL: https://issues.apache.org/jira/browse/GROOVY-8156
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.4.10
         Environment: Linux x64 java8 
            Reporter: Sascha Frinken
            Priority: Blocker


After upgrading groovy from  2.4.7 to 2.4.10 all classes using the 
`groovy.beans.ListenerList` annotation fail to compile.
The error message is:
{noformat}
Caught: BUG! exception in phase 'canonicalization' in source unit 
'/tmp/fsck/bug.groovy' ClassNode#getTypeClass for Event is called before the 
type class is set 
BUG! exception in phase 'canonicalization' in source unit 
'/tmp/fsck/bug.groovy' ClassNode#getTypeClass for Event is called before the 
type class is set 
{noformat}
Code to reproduce:
{noformat}
class Event {
}

interface EventListener {
        void doSomething(Event e)
}

class EventHandler {
        @groovy.beans.ListenerList
        List<EventListener> listeners
}

def eh = new EventHandler()
eh.addEventListener({ println it} as EventListener)
eh.fireDoSomething(new Event())
{noformat}

Complete steps:
{noformat}
% sdk u groovy 2.4.7

Using groovy version 2.4.7 in this shell.
% cat bug.groovy 
class Event {
}

interface EventListener {
        void doSomething(Event e)
}

class EventHandler {
        @groovy.beans.ListenerList
        List<EventListener> listeners
}

def eh = new EventHandler()
eh.addEventListener({ println it} as EventListener)
eh.fireDoSomething(new Event())
% groovy -v
Groovy Version: 2.4.7 JVM: 1.8.0_121 Vendor: Oracle Corporation OS: Linux
% groovy bug.groovy # WORKS 
Event@762ef0ea
% sdk u groovy 2.4.10       

Using groovy version 2.4.10 in this shell.
% groovy -v                
Groovy Version: 2.4.10 JVM: 1.8.0_121 Vendor: Oracle Corporation OS: Linux
% groovy bug.groovy # FAILS
Caught: BUG! exception in phase 'canonicalization' in source unit 
'/tmp/fsck/bug.groovy' ClassNode#getTypeClass for Event is called before the 
type class is set 
BUG! exception in phase 'canonicalization' in source unit 
'/tmp/fsck/bug.groovy' ClassNode#getTypeClass for Event is called before the 
type class is set 
{noformat}




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to