title: How can you type hint within the threading (->) macro?
body: <p>I have some Clojure code that is trying to interop through a couple layers of Java code (in this case, <a href="http://docs.oracle.com/javase/7/docs/api/index.html?java/nio/file/Path.html" rel="noreferrer"><code>java.nio.Path</code></a> by way of <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/WatchEvent.Kind.html" rel="noreferrer"><code>java.nio.file.WatchEvent&lt;?&gt;</code></a>:</p>
  
  <pre><code>(defn unroll-event
    [^WatchEvent event]
    { :kind (.kind event)
      :context (.context event)
      :path (-&gt; event .context .toAbsolutePath .toString)})
  </code></pre>
  
  <p>In this code, I have type hinted <code>event</code>, so I would think it <em>should</em> be able to figure out what <code>.context</code> is supposed to return, and as such, be able to figure out what <code>.toAbsolutePath</code> and <code>.toString</code> do.  I think in this case, since <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/WatchEvent.html#context%28%29" rel="noreferrer"><code>.context</code></a> is defined has returning a generic type <code>T</code>, I am wondering if I can type hint the call to <code>.context</code>.  I've tried just prepending <code>^java.nio.file.Path</code> to <code>.context</code>, and <code>^Path</code> and <code>^String</code> to <code>.toAbsolutePath</code> and <code>toString</code>, respectively, but I still get the warnings:</p>
  
  <pre><code>Reflection warning, junkcode/core.clj:28 - reference to field toAbsolutePath can't be resolved.
  Reflection warning, junkcode/core.clj:28 - reference to field toString can't be resolved.
  </code></pre>
  
  <p>Is there something I can do in this case?  Is it because <code>-&gt;</code> is a macro and there are special rules for type hinting within that?</p>