Unnecessary reflection with `indexOf` on vector

Description

This generates a reflection warning:

This does not:

The only difference is whether the elements of the vector are literal, which shouldn't affect the call to indexOf.

Environment

None

Activity

Show:
Alex Miller
August 7, 2018, 6:51 PM

I believe what's happening here is that in the first case, it gets typed as a PersistentVector (concrete data structure read by the reader). PV implements Collection and so requires no reflection.

In the second case, the vector requires evaluation and its type is IPersistentVector (the interface). IPV does not extend Collection (its independent of that interface) and so it can't find the indexOf method.

Stepping back from both, we're doing Java interop on an object that we are expecting to be a Collection. I'm somewhat on the fence about whether we should expect ids to carry this info when performing interop on it here. Depends how much you think that the abstract Clojure vector collection is a Java collection (vs the implementation of one).

Doesn't seem easily "fixable" to me in ways that are clean.

Assignee

Unassigned

Reporter

import

Labels

Approval

None

Patch

None

Affects versions

Priority

Minor