diff --git a/clos-transform.lisp b/clos-transform.lisp index 18a80d6a3683bf142d297f5205eeab640d6ca076..ab504d8300333638985216bffd74eca54cc8c564 100644 --- a/clos-transform.lisp +++ b/clos-transform.lisp @@ -263,10 +263,11 @@ (defun clos-type-to-protobuf-type (type &optional type-filter enum-filter) "Given a Lisp type, returns a Protobuf type, a class or primitive type, whether or not to pack the field, and (optionally) a set of enum values." - (let ((type (if type-filter (funcall type-filter type) type)) - (list-of-list-of (list-of-list-of))) - (flet () - (if (listp type) + (let* ((type (if type-filter (funcall type-filter type) type)) + (list-of-list-of (list-of-list-of)) + (expanded-type (type-expand type))) + (cond + ((listp type) (destructuring-bind (head &rest tail) type (case head ((or) @@ -346,8 +347,11 @@ (multiple-value-bind (type class) (lisp-type-to-protobuf-type (first tail)) (values type class (packed-type-p class))) - (lisp-type-to-protobuf-type type))))) - (lisp-type-to-protobuf-type type))))) + (lisp-type-to-protobuf-type type)))))) + ((not (equal type expanded-type)) + (clos-type-to-protobuf-type expanded-type)) + (t + (lisp-type-to-protobuf-type type))))) (defun lisp-type-to-protobuf-type (type) (case type diff --git a/utilities.lisp b/utilities.lisp index d8fedc6a393308afd5265e5ba32d4d86c3b40ecc..7195f3ab33973913ed259a47f5c58a4f01f6807a 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -314,6 +314,15 @@ (deftype sfixed32 () '(signed-byte 32)) (deftype sfixed64 () '(signed-byte 64)) +;; Type expansion +(defun type-expand (type) + #+allegro (excl:normalize-type type :default type) + #+ccl (ccl::type-expand type) + #+clisp (ext:type-expand type) + #+cmu (kernel:type-expand type) + #+lispworks (type:expand-user-type type) + #+sbcl (sb-ext:typexpand type) + #-(or allegro ccl clisp cmu lispworks sbcl) type) ;;; Code generation utilities