[
https://issues.apache.org/jira/browse/GROOVY-7933?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15485466#comment-15485466
]
Jose Ignacio Acin Pozo commented on GROOVY-7933:
------------------------------------------------
Of course, your resolution makes more sense. I was not taking into account the
widening possibility, just the boxed/unboxed possibilities for an Integer.
I think you meant:
{code}
​class Demo {
String a(int i) { 'int' }
String a(Integer bigI) { 'Integer' }
void test() {
String result = a(42)
// 'int' instead of 'Integer'
assert result == 'int'
}
static void main(args) {
String result = new Demo().a(42)
assert result == 'Integer'
new Demo().test()
}
}
{code}
This behaviour is way too confusing and I wonder how it went unnoticed for so
many years, or if there was a real reason indeed for doing it this way and it
is just not documented/explained properly.
> 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)