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

John Wagenleitner commented on GROOVY-7933:
-------------------------------------------

It seems to work as expected for all primitives except for {{boolean}} and 
{{char}}.  Looks like those primitive types are not taken into account when 
calculating the method parameter distances which is causing the method taking 
an {{Object}} to be selected first.

https://github.com/apache/groovy/blob/53b99ebb460ae26fd8483bc894cc3703cd7af48f/src/main/org/codehaus/groovy/runtime/MetaClassHelper.java#L206-L231

Both {{boolean}} and {{char}} do not seem to be eligible for conversion to 
other types which may explain why they are missing from the distance table.  
But perhaps they should be added and have a distance to the other types set to 
-1 except for their associated wrapper class and Object or maybe handled 
specially in the {{getPrimitiveDistance(Class from, Class to)}} method so as 
not to complicate the distance tables.

> Incorrect boxing of boolean primitive types
> -------------------------------------------
>
>                 Key: GROOVY-7933
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7933
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.7
>            Reporter: Henri Tremblay
>
> A boolean primitive type seems to be boxed for no apparent reason. See the 
> example below. The problem disappear when using @CompileStatic or if 
> explicitly casting to (boolean).
> {code:java}
> public class Demo {
>    public void a(boolean a){
>        System.out.println("boolean was called");
>    }
>    public void a(Object a){
>        System.out.println("Object was called");
>    }
> }
> class Groovy {
>    static void main(String[] args) {
>        def demo = new Demo()
>        demo.a(true)
>    }
> }
> {code}
> *Output:*
> Object was called



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

Reply via email to