<< Back to previous view

[CLJ-1173] One-arg protocol functions whose name begins in a dash generates a call to a wrong field in the emitted code Created: 01/Mar/13  Updated: 17/May/13  Resolved: 17/May/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Meikel Brandmeyer Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Clojure 1.4

(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))


(. ~(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:

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

Comment by Gabriel Horner [ 17/May/13 1:36 PM ]

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

Generated at Mon Jan 22 14:47:50 CST 2018 using JIRA 4.4#649-r158309.