Clojure

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

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.3
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

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

user=> (defn f1 ^String [^String s] s)
#'user/f1
user=> (f1 "foo")
"foo"
user=> (defn f2 ^long [^String s ^long i] i)
#'user/f2
user=> (f2 "foo" 1)
1
user=> (defn f3 ^String [^String s ^long i] s)                                       
#'user/f3
user=> (f3 "foo" 1)
AbstractMethodError user$f3.invokePrim(Ljava/lang/Object;J)Ljava/lang/Object;  user/eval8 (NO_SOURCE_FILE:6)

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].

  1. CLJ-850.patch
    18/Oct/11 2:54 PM
    2 kB
    Ben Smith-Mannschott
  2. CLJ-850-conform-to-invokePrim.diff
    19/Dec/12 3:41 PM
    2 kB
    Ghadi Shayban
  3. CLJ-850-test.patch
    15/Oct/11 11:54 AM
    2 kB
    Ben Smith-Mannschott
  4. clj-850-type-hinted-fn-abstractmethoderror-patch4.txt
    01/Nov/12 7:22 PM
    4 kB
    Andy Fingerhut

Activity

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: