Clojure

extend-type doesn't type-hint correctly as promised by the doc when the class is determined at run-time

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

extend-type works with non-constant expressions as its type:

(extend-type (class 1) proto (protof [this]))

However, in this case this will get tagged with `(class 1)`, which is clearly wrong; the doc explicitely states that the args will be proberly type-hinted: "[..] Propagates the class as a type hint on the first argument of all fns."

I don't know if extend-type is not supposed to work with non-constant Classes, in which case it should be stated in the doc or if the current behaviour is wrong.

Activity

Hide
Andy Fingerhut added a comment -

Eastwood as of around version 0.2.1 (or maybe have to wait until not-yet-released 0.2.2) will warn about such incorrect tags, if the :wrong-tag linter is enabled – it is by default. The section of Eastwood's documentation on this linter has a subsection specifically on extend-type and extend-protocol, primarily written so Andy can have a place to refer to this later after he forgets the details again.

https://github.com/jonase/eastwood#wrong-tag

(you have to scroll down a page or two to get to the subsection on extend-type / extend-protocol)

Show
Andy Fingerhut added a comment - Eastwood as of around version 0.2.1 (or maybe have to wait until not-yet-released 0.2.2) will warn about such incorrect tags, if the :wrong-tag linter is enabled – it is by default. The section of Eastwood's documentation on this linter has a subsection specifically on extend-type and extend-protocol, primarily written so Andy can have a place to refer to this later after he forgets the details again. https://github.com/jonase/eastwood#wrong-tag (you have to scroll down a page or two to get to the subsection on extend-type / extend-protocol)

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated: