javaclojurereification

Clojure deftype referencing other type


Trying to use one type from another type doesn't seem to work:

(deftype Foo [^int a ^int b])
(definterface Bars (^Foo makefoo []))

(deftype Bar [^int a ^int b] Bars (^Foo makefoo [this] (Foo. 1 2)))
;java.lang.NoClassDefFoundError: java/lang/Foo.

How do I get Foo to be visible to Bar?


Solution

  • If you specify the full namespace for the hint in definterface, everything seems to work correctly.

    (ns com.bar)
    
    (definterface Bars 
      (^com.bar.Foo makefoo []))