Clojure

Type hinting for array classes does not work in binding forms

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    replicated on OpenJDK 7u9 on Ubuntu 12.04, and Hotspot 1.6.0_37 on OSX Lion

Description

Type hints don't work as expected in binding forms.

The following form results in a reflection warning:

(let [^{:tag (Class/forName "[Ljava.lang.Object;")} a (make-array Object 2)]
(aget a 0))

However, hinting does appear to work correctly on vars:

(def ^{:tag (Class/forName "[Ljava.lang.Object;")} a (make-array Object 2))
(aget a 0) ;; no reflection warning

Activity

Luke VanderHart made changes -
Field Original Value New Value
Description Type hints don't work as expected in binding forms.

The following form results in a reflection warning:

(let [^{:tag (Class/forName "[Ljava.lang.Object;")} a (make-array Object 2)]
  (aget a 0))

However, hinting does appear to work correctly on vars:

(def ^{:tag (Class/forName "[Ljava.lang.Object;")} a (make-array Object 2))
(aget a 0) ;; no reflection warning
Type hints don't work as expected in binding forms.

The following form results in a reflection warning:

    (let [^{:tag (Class/forName "[Ljava.lang.Object;")} a (make-array Object 2)]
      (aget a 0))

However, hinting does appear to work correctly on vars:

    (def ^{:tag (Class/forName "[Ljava.lang.Object;")} a (make-array Object 2))
    (aget a 0) ;; no reflection warning
Alex Miller made changes -
Labels Compiler bug interop typehints

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: