Swift type metadata
summary
Claims that Swift runtime exposes usable type metadata and reads type metadata via unsafeBitCast to extract names and layout. Demonstrates reproducing the metadata memory model, reproduces runtime memory layout and implements a prototype that prints type names and instantiates values by walking descriptors, so builds a stub generator to instantiate types. It executes successfully but warns metadata format changes (Swift 4 → 5), is fragile and inefficient, and method rewrites or optimizer-driven static dispatch can break hacks.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 0:53Getting type name
- 1:39What is type metadata
- 4:06Swift runtime
- 4:58Type
- 8:50Relative pointer
- 9:27Extract type name
- 10:35Get type name
- 11:35Mirror API
- 12:04Recreate memory layout
- 13:08OSS metadata
- 13:45JSON metadata
- 14:23rust usage
- 19:15summary
related talks
38mType-safe meta programming in Swift? Lets talk about Sourcery.
57mExploring Swift Memory Layout
49mState of Swift Internals: Swift 4 & 5
40mSwift type inference is simple! Or is it?
12mFeatherweight Swift: A Core Calculus for Swift’s Type System
27mAST Meta-programming
39mSwift and You
34mSo You Think You Know Swift?
