I have a question on generics. I need to interface with Tasks. So I want to make a task from a result. When I try:
`(System.Threading.Tasks.Task/Run
(sys-func [System.Object] [] nil))`
It works,
but when I try:
(^|System.Threading.Tasks.Task1[System.Object]|
System.Threading.Tasks.Task/FromResult
nil))`
I get an error on compilation (loading a program with incorrect format). Ive tried to put the type hint on several places. But simply cannot get it to work. (It compiles when ai move the type hint before the open paren, but then it fails on execution). Is this supported? and how?
Yes:
(^|System.Threading.Tasks.Task`1[System.Object]|
System.Threading.Tasks.Task/FromResult
(type-args System.Object)
nil))Without the first meta tag, it also compiles fine:
(System.Threading.Tasks.Task/FromResult
(type-args System.Object)
nil))The "loading a program with incorrect format" is not very helpful. The compiler should catch bad IL generation before that. I'll see what I can do.
BTW, if you supply type-args and they are not needed or have the wrong count, one gets more informative error messages:
The type or method has 1 generic parameter(s), but 2 generic argument(s) were provided. A generic argument must be provided for each generic parameter.
Wrong number of args (2) passed to: clojure.core/type-args--7168
(Maybe the latter could be improved.)
Issue created: [CLJCLR-165](https://clojure.atlassian.net/jira/software/c/projects/CLJCLR/issues/CLJCLR-165).
The fix will be in the next release.
Found it, use type-args
Post the working code for reference?