[
https://issues.apache.org/jira/browse/GROOVY-7420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Pascal Schumacher resolved GROOVY-7420.
---------------------------------------
Resolution: Fixed
Assignee: Pascal Schumacher (was: Cédric Champeau)
Fix Version/s: 2.4.6
Pull request merged. Thanks!
> 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: Pascal Schumacher
> Labels: test
> Fix For: 2.4.6
>
>
> 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)