Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 176: Add support for :extend-via-metadata in defprotocol #178

Merged
merged 1 commit into from Jul 12, 2023

Conversation

ALai57
Copy link
Contributor

@ALai57 ALai57 commented Oct 18, 2022

A solution for the problem mentioned in #176 - that Clojure 1.10 added support for options in the defprotocol macro https://clojure.org/reference/protocols#_extend_via_metadata. Currently, the supported options are limited to :extend-via-metadata, which adds two forms before the actual method definitions.

This PR checks to see if the :extend-via-metadata key is present in the defprotocol body, and accounts for its presence or absence.

@@ -11,6 +11,8 @@
(is (= (count (marginalia.parser/parse "(ns test)\n\"some string\"")) 1))
(is (= (count (marginalia.parser/parse "(ns test (:require [marginalia.parser :as parser]))\n(defn foo [] ::parser/foo)")) 1)))

(deftest extend-via-metadata
(is (marginalia.parser/parse "(ns test)\n(defprotocol Foo \"Does a Foo\" :extend-via-metadata true (do-foo! [_ opts] \"Foo!\"))")))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old behavior is that this would throw an exception when :extend-via-metadata was present, so I thought that checking that it returns a truthy value (and doesn't throw) was a sufficient test.

@benjamin-bader
Copy link
Collaborator

Wow, sorry that this PR has languished for so long. I can merge, but do not have the ability to make a release.

Thank you, belatedly, for your contribution!

@benjamin-bader benjamin-bader merged commit e8a8524 into clj-commons:master Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants