Hinting the arg vector of a primitive-taking fn with a non-primitive type results in AbstractMethodError when invoked

Description

Hinting the arg vector of a primitive-taking fn with a non-primitive type results in AbstractMethodError when invoked.

Solution: Add check to emit invokePrim with return type of double or long if appropriate, otherwise do prior behavior of emitting return type of Object.

Patch: The CLJ-850-conform-to-invokePrim.diff patch is constructed per Rich's feedback, and appears good to me [Stu].

Environment

None

Attachments

4

Activity

Show:

Andy Fingerhut December 22, 2012 at 4:53 AM

Presumptuously changing state from Incomplete back to Vetted after Ghadi Shayban added the patch CLJ-850-conform-to-invokePrim.diff dated Dec 19 2012 after the status was changed to Incomplete.

Ghadi Shayban December 19, 2012 at 9:41 PM

Does this new patch address the issue and concerns? (This incorporates Ben's tests from the previous patch, wasn't sure how to attribute him on that hunk) CLJ-850-conform-to-invokePrim.diff

Rich Hickey December 19, 2012 at 2:03 PM

Still no patch incorporating my feedback, afaict. Pushing to next release.

Mike Anderson December 9, 2012 at 9:42 PM

+10 for solving this issue: it keeps biting me in 1.4 and wouuld love to see in 1.5

I'm not familiar with the Clojure compiler internals, but looking at the approach, shouldn't we produce a primitive method with a different name (since Java doesn't support overloading on return types as Rich correctly points out). Also I think there should be 4 methods:

R invokePrimExact(P x) - the actual method, used when compiler can infer
R invokePrimExact(O x) - delegates, used when compiler can't infer type of x
Object invokePrim(P x) - primitive method, conforms to IFn$PO interface, delegates
Object invoke(Object x) - general method, delegates

I think this solves all the important cases?

Andy Fingerhut November 2, 2012 at 1:22 AM

clj-850-type-hinted-fn-abstractmethoderror-patch4.txt dated Nov 1 2012 is same as Ben Smith-Mannschott's CLJ-850.patch and CLJ-850-test.patch, except it has been combined into one patch and does not create a new test source file.

Completed

Details

Assignee

Reporter

Approval

Patch

Priority

Affects versions

Fix versions

Created October 9, 2011 at 9:10 PM
Updated August 15, 2013 at 12:13 AM
Resolved August 15, 2013 at 12:13 AM