Fix reflection errors

Description

I get several reflection errors compiling math.combinatorics 0.1.1 on Clojure 1.8.

They were quite confusing to fix, but refactoring loops into multi-arity functions consistently fixed these errors.

Environment

None

Attachments

1
  • 04 May 2016, 02:32 AM

Activity

Show:

Mark Engelberg May 18, 2016 at 11:54 AM

Auto-boxing loop warnings addressed as of version 0.1.2

Ambrose Bonnaire-Sergeant May 4, 2016 at 2:32 AM

New patch that explicitly boxes Long's to work around reflection errors, as suggested by Mark.

Mark Engelberg May 4, 2016 at 1:10 AM

Sure. I'm pretty sure there's no performance penalty in its current form, but if you find the warnings a nuisance and don't mind creating another patch, that would be great.

Ambrose Bonnaire-Sergeant May 3, 2016 at 9:26 PM

Ah. My understanding here is limited. Would you like me to work on another patch with those suggestions?

Mark Engelberg May 3, 2016 at 8:48 PM

These loop auto-boxing warnings are because integer literals are now read in as primitive longs (since 1.6?), but these loops want boxed longs.

The simplest fix, I think, would be to replace the literals in the loop args with boxed longs. So, for example, 1 becomes (Long. 1). I believe that this is what the compiler does automatically when it sees that recur isn't passing in a primitive long (thus the warning that it is auto-boxing the loop arg), so I don't think it would have any impact on performance (this isn't actually a warning that it needs to do reflection at runtime), but it would make the warning disappear.

Breaking the loop out into a separate function strikes me as a heavy-handed solution (it makes the warning disappear because Clojure boxes numbers on function calls unless otherwise annotated, but there's really no need to break it into a separate function).

Completed

Details

Assignee

Reporter

Priority

Created May 3, 2016 at 6:40 PM
Updated May 18, 2016 at 11:54 AM
Resolved May 18, 2016 at 11:54 AM