java interop failure
Leo said: "it may be a cloroutine bug, move .readLine in a wrapper function"
#?(:clj (defn readerReadLine [r] (.readLine r)))
#?(:clj
(defn file-stream [uri]
(m/ap
(with-open [r (clojure.java.io/reader uri)]
(loop []
(m/amb
(m/? (m/via m/blk (.readLine r))) #_(readerReadLine r) ; ------------ here
(recur)))))))
As written, crashes with below error. Wrapping .readLine in a clojure fn resolves the issue.
#error {
:cause "No matching field found: readLine for class java.io.BufferedReader"
:via
[{:type java.lang.IllegalArgumentException
:message "No matching field found: readLine for class java.io.BufferedReader"
:at [clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 434]}]
Also encountering this, doing (clojure.walk/macroexpand-all '(cr {} (.take 'anything))) shows that it expands a method call into field retrieving. Moving interop into wrapper function works.
(do (def arr (java.util.ArrayList.)) (cloroutine.impl.analyze-clj/analyze nil '(.size arr)) results in host-interop. impl.cljc#L251 emits a field access for that (which would be wrong).
Notice that host-interop mean "Node for a no-arg host interop call or for a host interop field access" (field access (cloroutine.impl.analyze-clj/analyze nil '(.-in System)) also results in host-interop).
Also notice (. System in), (. System -in), (do (def arr (java.util.ArrayList.)) (. arr size)) all works.
For host-interop just replace built field access with (:m-or-f ast) would work.
Here is the try https://github.com/leonoel/cloroutine/compare/master...lotuc:cloroutine:fix/host-interop