File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -9965,17 +9965,17 @@ reduces them without incurring seq initialization"
99659965 false )))
99669966
99679967(defn- dominates
9968- [x y prefer-table]
9969- (or (prefers* x y prefer-table) (isa? x y)))
9968+ [x y prefer-table hierarchy ]
9969+ (or (prefers* x y prefer-table) (isa? hierarchy x y)))
99709970
99719971(defn- find-and-cache-best-method
99729972 [name dispatch-val hierarchy method-table prefer-table method-cache cached-hierarchy]
99739973 (let [best-entry (reduce (fn [be [k _ :as e]]
99749974 (if (isa? @hierarchy dispatch-val k)
9975- (let [be2 (if (or (nil? be) (dominates k (first be) prefer-table))
9975+ (let [be2 (if (or (nil? be) (dominates k (first be) prefer-table @hierarchy ))
99769976 e
99779977 be)]
9978- (when-not (dominates (first be2) k prefer-table)
9978+ (when-not (dominates (first be2) k prefer-table @hierarchy )
99799979 (throw (js/Error.
99809980 (str " Multiple methods in multimethod '" name
99819981 " ' match dispatch value: " dispatch-val " -> " k
Original file line number Diff line number Diff line change 243243(defmulti foo2 ' identity )
244244(defmethod foo2 ' 0 [x] x )
245245
246+ (def three-levels-h (-> (make-hierarchy )
247+ (derive :parent :gparent )
248+ (derive :child :parent )))
249+
250+ (defmulti multi-with-h (fn [v] v) :hierarchy #'three-levels-h)
251+ (defmethod multi-with-h :gparent [_] :gparent )
252+ (defmethod multi-with-h :parent [_] :parent )
253+
246254(deftest test-multimethods-2
247255 (let [r (rect 4 13 )
248256 c (circle 12 )]
272280 (is (not (my-map? not-m))))
273281 ; ; multimethod hashing
274282 (is (= foo2' (ffirst {foo2' 1 })))
283+ (is (= :parent (multi-with-h :child )))
275284)))
276285
277286(deftest test-transducers
You can’t perform that action at this time.
0 commit comments