core: delete seed fns shadowed by the overlay; fix methods/remove-all-methods
The seed copies of inst?/inst-ms and the multimethod table ops (get-method/methods/remove-method/remove-all-methods/prefer-method) are dead code — the overlay redefines all of them (20-coll.clj, 30-macros.clj) — so they're deleted along with duplicate bindings-table entries (unreduced, eduction, unchecked-inc/dec/add/subtract). New spec rows for methods/remove-all-methods caught two real bugs in the evaluator's setup fns: methods-setup returned the live host table (count rejected it, and callers could mutate dispatch state), and remove-all-methods-setup swapped in a fresh table the dispatch closure never saw. methods now returns a phm snapshot; remove-all-methods clears in place.
This commit is contained in:
parent
1a2841b02f
commit
a06c39266a
3 changed files with 24 additions and 34 deletions
|
|
@ -15,7 +15,15 @@
|
|||
["get-method" "\"one\""
|
||||
"(do (defmulti f identity) (defmethod f 1 [_] \"one\") ((get-method f 1) 1))"]
|
||||
["remove-method" :throws
|
||||
"(do (defmulti f identity) (defmethod f 1 [_] \"one\") (remove-method f 1) (f 1))"])
|
||||
"(do (defmulti f identity) (defmethod f 1 [_] \"one\") (remove-method f 1) (f 1))"]
|
||||
["methods" "\"one\""
|
||||
"(do (defmulti f identity) (defmethod f 1 [_] \"one\") ((get (methods f) 1) 1))"]
|
||||
["methods count" "2"
|
||||
"(do (defmulti f identity) (defmethod f 1 [_] \"one\") (defmethod f 2 [_] \"two\") (count (methods f)))"]
|
||||
["remove-all-methods" :throws
|
||||
"(do (defmulti f identity) (defmethod f 1 [_] \"one\") (defmethod f 2 [_] \"two\") (remove-all-methods f) (f 1))"]
|
||||
["remove-all-methods empties the table" "0"
|
||||
"(do (defmulti f identity) (defmethod f 1 [_] \"one\") (remove-all-methods f) (count (methods f)))"])
|
||||
|
||||
(defspec "multimethods / hierarchies"
|
||||
["derive + isa?" "true" "(do (derive ::child ::parent) (isa? ::child ::parent))"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue