(defn infer-if [env e]
(let [{{:keys [op form]} :test} e
then-tag (infer-tag env (:then e))]
(if (and #?(:clj (= op :constant)
:cljs (keyword-identical? op :constant))
(not (nil? form))
(not (false? form)))
then-tag
(let [else-tag (infer-tag env (:else e))]
(cond
(or #?(:clj (= then-tag else-tag)
:cljs (symbol-identical? then-tag else-tag))
#?(:clj (= else-tag IGNORE_SYM)
:cljs (symbol-identical? else-tag IGNORE_SYM))) then-tag
#?(:clj (= then-tag IGNORE_SYM)
:cljs (symbol-identical? then-tag IGNORE_SYM)) else-tag
;; TODO: temporary until we move not-native -> clj - David
(and (or (some? (get NOT_NATIVE then-tag)) (type? env then-tag))
(or (some? (get NOT_NATIVE else-tag)) (type? env else-tag)))
'clj
:else
(if (and (some? (get BOOLEAN_OR_SEQ then-tag))
(some? (get BOOLEAN_OR_SEQ else-tag)))
'seq
(let [then-tag (if #?(:clj (set? then-tag)
:cljs (cljs-set? then-tag))
then-tag #{then-tag})
else-tag (if #?(:clj (set? else-tag)
:cljs (cljs-set? else-tag))
else-tag #{else-tag})]
(into then-tag else-tag))))))))