We're updating the issue view to help you get more done. 

External type hint inconsistency between regular functions and primitive functions

Description

Consider the following example.

1 2 3 4 5 6 (set! *warn-on-reflection* true) (defn f [n] (java.util.ArrayList. (int n))) (let [al ^java.util.ArrayList (f 10)] (.add al 23))

As expected this does not warn about reflection. The following example shows the same scenario for a primitive function.

1 2 3 4 5 6 7 (set! *warn-on-reflection* true) (defn g [^long n] (java.util.ArrayList. n)) (let [al ^java.util.ArrayList (g 10)] (.add al 23)) ; Reflection warning, NO_SOURCE_PATH:2:3 - call to method add on java.lang.Object can't be resolved (no such method).

So the behavior of external type hints is inconsistent for regular functions and primitive functions.
Most likely, the external type hint information is somehow ignored for primitive functions since the case where they return no primitive value is not treated separately.

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

Triaged

Patch

Code

Affects versions

Release 1.6

Priority

Minor