feat(swift): dynamic any serializer for polymorphism#3368
Merged
chaokunyang merged 4 commits intoapache:mainfrom Feb 19, 2026
Merged
feat(swift): dynamic any serializer for polymorphism#3368chaokunyang merged 4 commits intoapache:mainfrom
chaokunyang merged 4 commits intoapache:mainfrom
Conversation
pandalee99
approved these changes
Feb 19, 2026
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.
Why?
Swift xlang polymorphism currently relies on a custom
AnyAnimalbridge in the peer, which makes dynamic payload handling narrow and hard to extend. This PR adds first-class dynamicAnyserialization so polymorphic lists/maps can round-trip through the core runtime and macro-generated models directly.What does this PR do?
AnySerializer.swiftwith runtimeAnycodec support, including dynamic type info read/write, null sentinel handling, and dynamic payload encode/decode helpers.[Any],[String: Any], and[Int32: Any](including map key-type probing for dynamic map decode).WriteContext/ReadContextconvenience APIs and newForyoverloads for serializing/deserializing dynamic Any collections in both buffer and stream-style entry points.TypeResolverto parse dynamic wire type metadata and decode dynamic values (primitive/array/list/map/registered types) by id or name, with registration-mode tracking.RefReader.readRefValue(_:)support used by dynamic Any reference resolution.@ForyObjectmacro generation to supportAny,[Any],[String: Any], and[Int32: Any]fields with generated read/write paths and compatibility metadata handling; reject unsupportedSet<Any>and unsupported dictionary key types.ForySwiftXlangPeerpolymorphic handlers by removing the customAnyAnimalcodec and switching to native[Any]/[String: Any]round-trips.Related issues
Closes #3367
#1017 #3349
Does this PR introduce any user-facing change?
Benchmark