Class-name symbols self-evaluate; extends? matches host classes; ISO_INSTANT

A slash-free dotted symbol with a Capitalized final segment (java.util.Map,
clojure.lang.Named, java.time.Instant) now self-evaluates to its name string
instead of resolving to nil — jolt models a class as its name, so a library
can extend a protocol to, or instance?-check, a host class jolt has no shim
for. hc-resolve-global classifies these as :class; the analyzer emits a const.

extends? now matches when either the query or the registered tag is a dotted
suffix of the other, so (extends? P java.util.Collection) finds the impl
extend registered under the canonical short tag.

Add DateTimeFormatter/ISO_INSTANT (UTC, trailing Z).

These unblock loading clojure.data.json, which dispatches JSONWriter on
java.util.Map/Collection/CharSequence/Instant and defaults a formatter to
ISO_INSTANT.
This commit is contained in:
Yogthos 2026-06-24 14:17:34 -04:00
parent c26fd175f2
commit 21895cb932
7 changed files with 552 additions and 526 deletions

View file

@ -380,17 +380,19 @@
step)))
;; True when atype's methods were registered for this protocol (via extend /
;; extend-type). Tags are canonical host names or ns-qualified record names,
;; so a bare record name also matches its "ns.Name" tag.
;; extend-type). Tags are canonical host names or ns-qualified record names, so a
;; name matches its tag when either is a dotted suffix of the other — a bare
;; record name matches its "ns.Name" tag, and a query for a qualified host class
;; (java.util.Map) matches the canonical short tag (Map) extend registered it as.
(defn extends? [protocol atype]
(let [want (if (nil? atype) "nil" (name atype))
dotted (str "." want)
dlen (count dotted)]
suffix? (fn [long short]
(let [d (str "." short)]
(and (> (count long) (count d))
(= (subs long (- (count long) (count d))) d))))]
(boolean (some (fn [t]
(let [tn (name t)]
(or (= tn want)
(and (> (count tn) dlen)
(= (subs tn (- (count tn) dlen)) dotted)))))
(or (= tn want) (suffix? tn want) (suffix? want tn))))
(extenders protocol)))))
;; extend, the FUNCTION (extend-type's runtime sibling): protocol + method-map