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"
9965
9965
false )))
9966
9966
9967
9967
(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)))
9970
9970
9971
9971
(defn- find-and-cache-best-method
9972
9972
[name dispatch-val hierarchy method-table prefer-table method-cache cached-hierarchy]
9973
9973
(let [best-entry (reduce (fn [be [k _ :as e]]
9974
9974
(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 ))
9976
9976
e
9977
9977
be)]
9978
- (when-not (dominates (first be2) k prefer-table)
9978
+ (when-not (dominates (first be2) k prefer-table @hierarchy )
9979
9979
(throw (js/Error.
9980
9980
(str " Multiple methods in multimethod '" name
9981
9981
" ' match dispatch value: " dispatch-val " -> " k
Original file line number Diff line number Diff line change 243
243
(defmulti foo2 ' identity )
244
244
(defmethod foo2 ' 0 [x] x )
245
245
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
+
246
254
(deftest test-multimethods-2
247
255
(let [r (rect 4 13 )
248
256
c (circle 12 )]
272
280
(is (not (my-map? not-m))))
273
281
; ; multimethod hashing
274
282
(is (= foo2' (ffirst {foo2' 1 })))
283
+ (is (= :parent (multi-with-h :child )))
275
284
)))
276
285
277
286
(deftest test-transducers
You can’t perform that action at this time.
0 commit comments