I reread your original post, sorry I saw that you managed to declare type
constrained methods. Then, what was your question about?
Type hinting for arguments works as well:
(definterface Name
(^"[S" method [^"[S" short-arg]))
(def p (proxy [Name] []
(method [^"[S" short-arg] short-arg)))
(.method p
(short-array [(short 10) (short 11)]))
Interesting, I didn't actually check the runtime behavior. Decompiler
> says, the emitted class names are bogus.
>
Do you mean the interface name?
> JVM probably doesn't cast on return, so it slips through. Have you
> tried hinting an argument?
>
I'm not sure what happens in case of arrays, but for simple return types it
definitely does the check.
(def p (proxy [Comparable] []
(^int compareTo [arg] arg) ;;doesn't matter
(^String toString [] 10))) ;;will throw ClassCastException on
invocation.
Cheers,
Ivan.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en