Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.3
Description
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):
class A { static String m(long p) { "primitive" } static String m(Long p) { "object" } } Long l = 42L A.m(l)
yields the following compilation error:
[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)]
The problem can be worked around by explicitely calling .longValue() on the Long.
Attachments
Issue Links
- is duplicated by
-
GROOVY-7454 [Static type checking] - Reference to method is ambiguous
- Closed