Clojure

One-arg protocol functions whose name begins in a dash generates a call to a wrong field in the emitted code

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojure 1.4

Description

(defprotocol P (-foo [this]))

This code generates a reflective call to a non-existing foo field instead of the correct -foo method.

I was told by Christophe Grand that changing the line 557 in core_deftype.clj from:

(. ~(with-meta target {:tag on-interface}) ~(or on-method method) ~@(rest gargs))

to

(. ~(with-meta target {:tag on-interface}) (~(or on-method method) ~@(rest gargs)))

is a quick fix. However I don't know too much about the compilation specifics of . to judge whether this is the correct fix.

Issue reproduction:

Clojure
user=> (set! *warn-on-reflection* true)
true
user=> (defprotocol P (-foo [this]))
P
Reflection warning, REPL:4 - reference to field foo can't be resolved.

Activity

Hide
Gabriel Horner added a comment -

CLJ-1202 addresses this exact issue with the same fix and includes tests

Show
Gabriel Horner added a comment - CLJ-1202 addresses this exact issue with the same fix and includes tests

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: