Uploaded image for project: 'Clojure'
  1. CLJ-1543

Type tags on argument vector appear to help avoid reflection when used with defn, but not with def foo (fn ...)

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: Release 1.6
    • Fix versions: None
    • Labels:

      Description

      I would have expected that both of the Java interop calls below would avoid reflection, but only the first involving f1 does.

      Clojure 1.6.0
      user=> (set! *warn-on-reflection* true)
      true
      user=> (defn f1 ^java.util.LinkedList [coll] (java.util.LinkedList. coll))
      #'user/f1
      user=> (def f2 (fn ^java.util.LinkedList [coll] (java.util.LinkedList. coll)))
      #'user/f2
      user=> (.size (f1 [2 3 4]))
      3
      user=> (.size (f2 [2 3 4]))
      Reflection warning, NO_SOURCE_PATH:5:1 - reference to field size can't be resolved.
      3
      

      Not sure if this has anything to do with CLJ-1232 Closed , but was discovered when testing variants of that issue.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jafingerhut Andy Fingerhut
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: