Move dispatch for unions into the kwargs
This commit is contained in:
parent
7ead50641b
commit
415c842af1
1 changed files with 6 additions and 2 deletions
|
|
@ -495,13 +495,17 @@
|
|||
;;; Union types
|
||||
|
||||
(defmethod c-layout ::union
|
||||
[[_union _dispatch types & {:as _opts} :as _type]]
|
||||
[[_union types & {:as _opts} :as _type]]
|
||||
(let [items (map c-layout types)]
|
||||
(MemoryLayout/unionLayout
|
||||
(into-array MemoryLayout items))))
|
||||
|
||||
(defmethod serialize-into ::union
|
||||
[obj [_union dispatch _types & {:keys [extract]}] segment scope]
|
||||
[obj [_union _types & {:keys [dispatch extract]} :as type] segment scope]
|
||||
(when-not dispatch
|
||||
(throw (ex-info "Attempted to serialize a union with no dispatch function"
|
||||
{:type type
|
||||
:value obj})))
|
||||
(let [type (dispatch obj)]
|
||||
(serialize-into
|
||||
(if extract
|
||||
|
|
|
|||
Loading…
Reference in a new issue