We're updating the issue view to help you get more done. 

Hints don't work with #() form of function

Description

Example showing how a local fn can be hinted but an anonymous function cannot:

1 2 3 4 5 6 7 8 9 ;; OK user> (let [ex (java.util.concurrent.Executors/newFixedThreadPool 1) f (fn [])] (.submit ex ^Runnable f)) nil ;; ERROR - this should work the same as the previous user> (let [ex (java.util.concurrent.Executors/newFixedThreadPool 1)] (.submit ex #())) CompilerException java.lang.IllegalArgumentException: More than one matching method found: submit, compiling:(/private/var/folders/7r/_1fj0f517rgcxwx79mn79mfc0000gn/T/form-init7901279404687292754.clj:3:9)

Cause: Functions have metadata, but Compiler does not look in them for type hints. Var expressions and local bindings use :tag metadata to override return of getJavaClass(). Compiler parses #() into a FnExpr, which always return AFunction as its class.

Proposed: Change FnExpr.getJavaClass() to return tag as type if it is available.

Patch: clj-1378-v2.diff

Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Priority

Major