Details
-
Type:
Enhancement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: Release 1.5, Release 1.6
-
Fix Version/s: None
-
Component/s: None
-
Labels:
Description
Primitive function and recur variables can't pass through a (try) cleanly; they're boxed to Object instead. This causes reflection warnings for fns or loops that use primitive types.
user=> (set! *warn-on-reflection* true) true user=> (fn [] (loop [t 0] (recur t))) #<user$eval676$fn__677 user$eval676$fn__677@3d80023a> user=> (fn [] (loop [t 0] (recur (try t)))) NO_SOURCE_FILE:1 recur arg for primitive local: t is not matching primitive, had: Object, needed: long Auto-boxing loop arg: t #<user$eval680$fn__681 user$eval680$fn__681@5419323a> user=> (fn [^long x] (recur (try x))) NO_SOURCE_FILE:1 recur arg for primitive local: x is not matching primitive, had: Object, needed: long CompilerException java.lang.IllegalArgumentException: recur arg for primitive local: x is not matching primitive, had: Object, needed: long, compiling:(NO_SOURCE_PATH:1:1)
Without commenting on the most desirable behavior, the following code does not cause reflection warnings: