Protocol dispatch through a deftype/reify's declared interfaces - #702
Merged
Merged
Conversation
value-host-tags reported only ("Object") for a reify and (tag "Object") for a
bare deftype, so an extend-protocol filed under an interface name could never
reach one — clojure.lang.IReduceInit, java.lang.Iterable, or an ancestor like
Associative for a type declaring IPersistentVector. Both now report their
declared interfaces plus the modeled ancestry the class graph already holds
(register-inline-protocol! files each declared interface as a super of the
type's tag), which is what instanceof answers on the JVM. A defrecord's extra
declared interfaces join its automatic map set the same way.
satisfies? agreed with the old dispatch, not with the JVM: it checked only the
type's own registry and answered false where an interface extension applied.
It now falls through to the same interface walk.
The type's own tag is still tried first, so an extend-type on the type wins,
and Object extensions still catch types that declare nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #701 (round 4), which is stacked on #697.
value-host-tagsreported only("Object")for a reify and(tag "Object")for a bare deftype, so anextend-protocolfiled under an interface name could never reach one —clojure.lang.IReduceInit,java.lang.Iterable, or an ancestor likeAssociativefor a type declaringIPersistentVector. Both now report their declared interfaces plus the ancestry the class graph already holds;register-inline-protocol!files each declared interface as a super of the type's tag, so the derivation is transitive and matchesinstanceof. A defrecord's extra declared interfaces join its automatic map set the same way.satisfies?agreed with the old dispatch rather than with the JVM — it consulted only the type's own registry and answered false where an interface extension applied. It now falls through to the same interface walk, so dispatch andsatisfies?give the same answer.The type's own tag is still tried first (an
extend-typeon the type wins), andObjectextensions still catch types that declare nothing.This is the last core item from the Grain gap audit (bead jolt-o3sw.13), split out of the round-1 reducible work.
Validation
make testgreen: exit 0, 0 new divergences, unit 1394/1394, 82 CI targetsmake gambitgenre-run (protocols.ss is concatenated into records-gambit.ss);gambitseedcheckpasses