which hasn't had any response.
prefers(x,y) visits ancestors by calling parents.invoke() recursively.
This visits the parents in the global hierarchy, not the multimethod's hierarchy.
Is this the intended behavior? Why would that be?
On the assumption that prefer-method should behave the same for a local vs the global-hierarchy, below are 2 unit tests.
MultiFn-prefers-with-local-hierarchy fails with a "Multiple methods" IllegalArgumentException.
(let [h (make-hierarchy)
h (derive h ::c0 ::b0)
h (derive h ::d0 ::c0)
h (derive h ::d0 ::a0)]
(defmulti local identity :hierarchy #'local-hierarchy)
(defmethod local ::a0 [x] [::a0 x])
(defmethod local ::c0 [x] [::c0 x])
(prefer-method local ::b0 ::a0)
(test/is (= [::c0 ::d0] (local ::d0)))))
(derive ::c1 ::b1)
(derive ::d1 ::c1)
(derive ::d1 ::a1)
(defmulti global identity)
(defmethod global ::a1 [x] [::a1 x])
(defmethod global ::c1 [x] [::c1 x])
(prefer-method global ::b1 ::a1)
(test/is (= [::c1 ::d1] (global ::d1))))
If this is in fact wrong, the fix is pretty easy. I'll submit a patch once it's confirmed this is a real problem.