The following is valid Clojure (focus on extend-type (class (log-window-proxy nil))
, as opposed to refering to a class literal):
(defn- log-window-proxy [state]
(proxy [javax.swing.JTextArea clojure.lang.IDeref] []
(deref [] state)
(scrollRectToVisible [rect]
(if @(:auto-scroll? state)
(proxy-super scrollRectToVisible rect)))))
(defprotocol LogWindow
(log [this message])
(clear [this]))
(extend-type (class (log-window-proxy nil))
LogWindow
(log [this message]
(println "message" message))
(clear [this]
nil))
However, when one inspects the :tag metadata that this
is given, it appears to have an somewhat odd form (since it remains a chain of calls, instead of a class literal):
(-> (extend-type (class (log-window-proxy nil))
LogWindow
(log [this message]
(println "message" message))
(clear [this]
nil)) quote macroexpand last :log second ffirst meta)
;; => {:tag (class (log-window-proxy nil))}
So, the :tag looks like a function call. Will the compiler end up invoking (class (log-window-proxy ...
to obtain a class that it can actually use as a type hint?
Otherwise I'd be worried that this :tag metadata was invalid, which might cause reflection warnings and additionally confuse arbitrary third-party tooling.