I couldn't find a way to use prerequisites for functions with type hinted vars. The root cause is related to how type hint works and it comes down to some limitation of with-redefs as explained in #295.
However, as a midje user I am expecting some workaround (when using with-redefs the workaround is to type hint the mocking function).
Can someone think of a way to define prerequisites for the following scenario?
There is a workaround exposed here but it requires to modify the code of the function that is tested which is not desirable in my case.
Can someone think of a workaround (or maybe a fix in midje) that will allow me to use prerequisites for type hinted functions without modifying the source code.
Here is a simple illustration of my use case:
This code causes an exception:
(defn bar [^String x ^long x])
(defn foo []
(bar "a" 1))
(fact
(foo ) => nil
(provided (bar "a" 1) => nil))
java.lang.ClassCastException: clojure.lang.AFunction$1 cannot be cast to clojure.lang.IFn$OLO
While this code works as expected
(defn bar [^String x ^long x])
(defn foo []
(#'bar "a" 1))
(fact
(foo ) => nil
(provided (bar "a" 1) => nil))