[ 
https://issues.apache.org/jira/browse/GROOVY-7481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14609200#comment-14609200
 ] 

Paul King commented on GROOVY-7481:
-----------------------------------

I can't remember the JIRA but I think this was an intentional change. It should 
be listed as a breaking change in one of the release notes. Groovy has an 
algorithm for finding the right method to use but from memory when the 
algorithm used to return multiple possibilities (not typical but easily 
possible with nulls) it used to just pick the first possible candidate from 
those found. This probably wasn't good behaviour in the first place but, even 
worse, the ordering of returned methods changed between JVM versions so the 
behaviour was unpredictable. We made the selection algorithm stricter to avoid 
that circumstance. Casting as above might be what you want or @CompileStatic 
inferencing might also work depending on what you are doing - though it might 
limit duck-typing possibilities or other dynamic behaviour that you might need.

> Update to Groovy 2.4.3 breaks existing code
> -------------------------------------------
>
>                 Key: GROOVY-7481
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7481
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.3
>            Reporter: Alexander Veit
>
> After update to Groovy 2.4.3 coll.addAll() fails for null values.
> groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method 
> our.package.OurCollection#addAll.
> Cannot resolve which method to invoke for [null] due to overlapping 
> prototypes between:
>       [interface java.util.Collection]
>       [interface java.lang.Iterable]
>       [interface java.util.Iterator]
>       at 
> groovy.lang.MetaClassImpl.chooseMostSpecificParams(MetaClassImpl.java:3238)
>       at 
> groovy.lang.MetaClassImpl.chooseMethodInternal(MetaClassImpl.java:3191)
>       at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:3134)
>       at 
> groovy.lang.MetaClassImpl.getMethodWithCachingInternal(MetaClassImpl.java:1325)
>       at groovy.lang.MetaClassImpl.createPojoCallSite(MetaClassImpl.java:3367)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(CallSiteArray.java:129)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:163)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
>       at test.run(test.groovy:62)
>       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
>       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:636)
> ...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to