Fork me on GitHub
#cursive
<
2017-03-21
>
pelletier08:03:25

Hi there! Given the two following Clojure files:

; file myprotocol.clj
(ns myprotocol)

(defprotocol MyProtocol
  (method-one [this arg]))

; file mytype.clj
(ns mytype
  (:require [myprotocol])
  (:import [myprotocol MyProtocol]))

(deftype MyType []
  MyProtocol
  (method-one [_ arg] (str "arg is:" arg)))
Cursive is having issues resolving method-one https://cl.ly/47383n1t370w Any idea what's up?

cfleming08:03:34

@pelletier When you’re implementing a protocol, you need an extra this parameter.

pelletier08:03:52

not sure what you mean

pelletier08:03:00

(method-one [this arg] ...) ?

cfleming08:03:51

Ah, no, sorry, you’re right

cfleming08:03:18

I think the problem is that you don’t need the import. What you’re doing there is implementing the interface generated by the protocol, and the method there will be called method_one.

cfleming08:03:05

I think you can delete the import, (:require [myprotocol :as p]) and then (deftype MyType [] p/MyProtocol ...)

cfleming08:03:48

No worries!

zylox13:03:52

oh...that explains a lot

cfleming18:03:15

It would probably be a good idea to have a warning that you’re implementing a protocol interface rather than the protocol itself.

yonatanel20:03:37

The Tools->REPL menu acts weird on a lib when I try to run tests. Sometimes the action to run tests is enabled and sometimes not, sometimes I can move to the tests namespace in REPL and sometimes not. What's the surest way to make it work consistently? I don't mind adding a bunch of redundant configuration if necessary.

yonatanel20:03:21

By moving to tests ns I mean requiring it or (in-ns ...) to it.

danielcompton21:03:18

I've noticed in the most recent EAP's that Refresh Leiningen Projects only works when you are in a project.clj file

danielcompton21:03:32

The old behaviour allowed it from anywhere (I think)

danielcompton21:03:46

Is this an intentional change?