You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend type structure representation to support class refinements
Summary:
[Human here: this was produced by Claude, with another Claude reviewing it and suggesting fixes. It's a prerequisite to supporting aliases and type constants whose right-hand-side is a type refinement.]
Add runtime support for type refinements (`I with { type T = ... }`) in TypeStructures. Refinements are represented by adding an optional `with_refinements` dict field to class kinds (T_class, T_interface, T_trait, T_enum, T_unresolved) rather than introducing a new TypeStructureKind.
Each entry in `with_refinements` is keyed by the type/ctx constant name and contains:
- `is_ctx`: whether this is a context constant refinement
- `equals`: for exact refinements (`type T = X`)
- `as`: for upper-bounded refinements (`type T as X`)
- `super`: for lower-bounded refinements (`type T super X`)
Changes:
- Emitter (`emit_type_constant.rs`): emit `with_refinements` as a sibling field of `classname`/`kind` when processing `Hrefinement` hints, and allow refinements in type aliases and type constants
- Runtime (`type-structure.cpp`): resolve `with_refinements` during T_unresolved resolution, generate display names via `refinementTypeName()`, and coerce refinement member types in `coerceToTypeStructure`
- Helpers (`type-structure-helpers.cpp/defs.h`): add `get_ts_refinement_types_opt()` accessor and string constants for refinement fields
- HHBBC (`type-structure.cpp`): resolve refinement types at compile time and track references within refinement members for dependency analysis
- Handle `with_refinements` presence in event-hook.cpp, irgen-types.cpp, interp.cpp, and type-system.cpp switch cases
- Add tests covering exact, upper-bounded, lower-bounded, and ctx refinements for both type aliases and type constants
Reviewed By: dlreeves
Differential Revision: D94346411
fbshipit-source-id: c82eb43a3129a400c9bab45c616f3b9edaa25320
0 commit comments