clj-commons / virgil

Recompile Java code without restarting the REPL
306 stars 21 forks source link

Reloading namespaces in arbitrary order causes problems #8

Closed miikka closed 7 years ago

miikka commented 7 years ago

I'm unable to use Virgil with Whidbey (or Ultra, which depends on Whidbey). I think the problem is that Virgil reloads Clojure namespaces in arbitrary order. It seems to break Whidbey:

First it [Virgil] reloads clojure.tools.nrepl.middleware.render-values which uses the old definition of Transport [protocol] and then it reloads clojure.tools.nrepl.transport, which creates a new definition for Transport.

I think this could be solved by making Virgil reload the namespaces in the dependency order. I quickly tried replacing Virgil's namespace reloading code with clojure.tools.namespace.repl/refresh-all and it fixed the problem. However, refresh-all is quite invasive: it unloads the namespaces before reloading them and loads all the Clojure files it can find, even if they weren't loaded in the first place. Would you be open to accepting such a patch?

ztellman commented 7 years ago

The recompilation step is already heavyweight, so this seems like a reasonable thing to do. I'd be happy to accept a PR.