diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2e9eae --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# http://editorconfig.org/ + +[*] +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 +end_of_line = lf + +[*.clj] +max_line_length = 120 + +[*.{html,css,mustache,js,jsx,ts,tsx,json}] +indent_size = 2 + +[*.{yaml,yml}] +indent_size = 2 diff --git a/src/methodical/impl/combo/threaded.clj b/src/methodical/impl/combo/threaded.clj index 21cb4e7..2615a9a 100644 --- a/src/methodical/impl/combo/threaded.clj +++ b/src/methodical/impl/combo/threaded.clj @@ -26,7 +26,7 @@ ([threader before-primary-afters] (comp (reducer-fn before-primary-afters) threader)) - ([threader primary-methods {:keys [before after around]}] + ([threader primary-methods {:keys [before after around], :as aux-methods}] (when-let [primary (combo.common/combine-primary-methods primary-methods)] (let [methods (concat before [primary] (reverse after)) threaded-fn (combine-with-threader threader methods) @@ -39,7 +39,9 @@ ([a b c] (threaded-fn a b c)) ([a b c d] (threaded-fn a b c d)) ([a b c d & more] (apply threaded-fn a b c d more))) - (vary-meta assoc :methodical/combined-method? true)) + (vary-meta assoc + :methodical/combined-method? true + :methodical/built-from {:primary primary-methods, :aux aux-methods})) around))))) (defmulti threading-invoker diff --git a/src/methodical/impl/multifn/cached.clj b/src/methodical/impl/multifn/cached.clj index ce839f5..55539fb 100644 --- a/src/methodical/impl/multifn/cached.clj +++ b/src/methodical/impl/multifn/cached.clj @@ -61,10 +61,11 @@ ;; cache for dispatch value. This way we don't end up with a bunch of duplicate methods impls for various ;; dispatch values that have the same effective dispatch value cached-effective-dv-method (.cached-method cache effective-dispatch-value) - method (or cached-effective-dv-method method)] + method (-> (or cached-effective-dv-method method) + (vary-meta assoc :methodical/cached-by dispatch-value))] ;; Make sure the method was cached for the effective dispatch value as well, that way if some less-specific ;; dispatch value comes along with the same effective dispatch value we can use the existing method (when-not cached-effective-dv-method - (i/cache-method! cache effective-dispatch-value method)) - (i/cache-method! cache dispatch-value method) + (i/cache-method! cache effective-dispatch-value (vary-meta method assoc :methodical/cached-for effective-dispatch-value))) + (i/cache-method! cache dispatch-value (vary-meta method assoc :methodical/cached-for dispatch-value)) method)))) diff --git a/src/methodical/impl/multifn/standard.clj b/src/methodical/impl/multifn/standard.clj index a2bb31f..771060f 100644 --- a/src/methodical/impl/multifn/standard.clj +++ b/src/methodical/impl/multifn/standard.clj @@ -93,7 +93,9 @@ (let [primary-methods (i/matching-primary-methods dispatcher method-table dispatch-value) aux-methods (i/matching-aux-methods dispatcher method-table dispatch-value)] (some-> (i/combine-methods method-combination primary-methods aux-methods) - (with-meta {:dispatch-value (effective-dispatch-value dispatcher dispatch-value primary-methods aux-methods)})))) + (with-meta {:dispatch-value (effective-dispatch-value dispatcher dispatch-value primary-methods aux-methods) + :methodical/built-for dispatch-value + :methodical/built-from {:primary primary-methods, :aux aux-methods}})))) (p.types/deftype+ StandardMultiFnImpl [^MethodCombination combo ^Dispatcher dispatcher