Details
-
Type:
Enhancement
-
Status:
In Progress
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: Reviewed Backlog
-
Component/s: None
-
Labels:None
-
Approval:Incomplete
Description
Problem:
When making java calls (or inlined functions), if both args and param are primitive, no widening conversion is used to locate the proper overloaded method/constructor.
Examples:
user=> (Integer. (byte 0)) java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Integer (NO_SOURCE_FILE:0) </code></pre> The above occurs because there is no Integer(byte) constructor, though it should match on Integer(int). <pre><code>user=> (bit-shift-left (byte 1) 1) Reflection warning, NO_SOURCE_PATH:3 - call to shiftLeft can't be resolved. 2
In the above, a call is made via reflection to Numbers.shiftLeft(Object, Object) and its associated auto-boxing, instead of directly to the perfectly adequate Numbers.shiftLeft(long, int).
Workarounds:
Explicitly casting to the formal type.
Ancillary benefits of fixing:
It would also reduce the amount of method overloading, e.g., RT.intCast(char), intCast(byte), intCast(short), could all be removed, since such calls would pass to RT.intCast(int).
Again, not sure if this is any help, but I've tested starting from Clojure head as of Feb 20, 2012, applying clj-792-reorg-reflector-patch2.txt attached to CLJ-792, and then applying clj-445-prim-conversion-update-2-patch.txt attached to this ticket, and the result compiles and passes all but 2 tests. I don't know whether those failures are easy to fix or not, or whether issues may have been introduced with these patches.