(validate {:keys [tag form env], :as ast})
Validate tags, classes, method calls.
Throws exceptions when invalid forms are encountered, replaces
class symbols with class objects.
Passes opts:
* :validate/throw-on-arity-mismatch
If true, validate will throw on potential arity mismatch
* :validate/wrong-tag-handler
If bound to a function, will invoke that function instead of
throwing on invalid tag.
The function takes the tag key (or :name/tag if the node is :def and
the wrong tag is the one on the :name field meta) and the originating
AST node and must return a map (or nil) that will be merged into the AST,
possibly shadowing the wrong tag with Object or nil.
* :validate/unresolvable-symbol-handler
If bound to a function, will invoke that function instead of
throwing on unresolvable symbol.
The function takes three arguments: the namespace (possibly nil)
and name part of the symbol, as symbols and the originating
AST node which can be either a :maybe-class or a :maybe-host-form,
those nodes are documented in the tools.analyzer quickref.
The function must return a valid tools.analyzer.jvm AST node.
Source
(defn validate
"Validate tags, classes, method calls.
Throws exceptions when invalid forms are encountered, replaces
class symbols with class objects.
Passes opts:
* :validate/throw-on-arity-mismatch
If true, validate will throw on potential arity mismatch
* :validate/wrong-tag-handler
If bound to a function, will invoke that function instead of
throwing on invalid tag.
The function takes the tag key (or :name/tag if the node is :def and
the wrong tag is the one on the :name field meta) and the originating
AST node and must return a map (or nil) that will be merged into the AST,
possibly shadowing the wrong tag with Object or nil.
* :validate/unresolvable-symbol-handler
If bound to a function, will invoke that function instead of
throwing on unresolvable symbol.
The function takes three arguments: the namespace (possibly nil)
and name part of the symbol, as symbols and the originating
AST node which can be either a :maybe-class or a :maybe-host-form,
those nodes are documented in the tools.analyzer quickref.
The function must return a valid tools.analyzer.jvm AST node."
{:pass-info {:walk :post :depends #{#'infer-tag #'analyze-host-expr #'validate-recur}}}
[{:keys [tag form env] :as ast}]
(let [ast (merge (-validate ast)
(when tag
{:tag tag}))]
(merge ast
(when (:tag ast)
(validate-tag :tag ast))
(when (:o-tag ast)
(validate-tag :o-tag ast))
(when (:return-tag ast)
(validate-tag :return-tag ast)))))