groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank Pavageau (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-7420) Cannot choose between primitive and object variants of an overloaded method
Date Sat, 01 Aug 2015 21:43:04 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-7420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Frank Pavageau updated GROOVY-7420:
-----------------------------------
    Labels: test  (was: )

> Cannot choose between primitive and object variants of an overloaded method
> ---------------------------------------------------------------------------
>
>                 Key: GROOVY-7420
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7420
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.4.3
>            Reporter: Frank Pavageau
>            Assignee: C├ędric Champeau
>              Labels: test
>
> The static type checked cannot choose which variant of a overloaded method with both
primitive and object parameters (e.g. {{long}} and {{Long}}) to use when the actual type of
the parameter is the object type (e.g. {{Long}}):
> {code}
> class A {
>     static String m(long p) {
>         "primitive"
>     }
>     static String m(Long p) {
>         "object"
>     }
> }
> Long l = 42L
> A.m(l)
> {code}
> yields the following compilation error:
> {noformat}
> [Static type checking] - Reference to method is ambiguous. Cannot choose between [java.lang.String
A#m(java.lang.Long), java.lang.String A#m(long)]
> {noformat}
> The problem can be worked around by explicitely calling {{.longValue()}} on the {{Long}}.



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

Mime
View raw message