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
Stop expanding type aliases during name resolution (Phase 2)
names_typealias() now creates TK_TYPEALIASREF nodes instead of expanding
aliases inline. The alias identity is preserved throughout the compiler
pipeline — type system, reach, and codegen unfold on demand at each
dispatch point.
All 1423 C++ compiler tests pass. All tools (pony-lsp, pony-lint,
pony-doc) and the full-program test runner build successfully.
Key changes across 24 files:
Names pass:
- names_typealias() creates TK_TYPEALIASREF via REPLACE instead of
reify+applycap+replace (names_applycap removed as dead code)
Expression pass:
- pass_expr handles TK_TYPEALIASREF constraint checking
- expr_nominal keeps TK_TYPEALIASREF in place (no unfold)
- find_infer_type unfolds aliases for tuple destructuring inference
- entity_access unfolds aliases for tuple element access (._1, ._2)
- check_auto_recover_newref unfolds aliases for auto-recovery eligibility
Refer pass:
- is_constructed_from unfolds aliases for "let x: Alias = x.create()"
Type system:
- subtype.c: is_literal unfolds TK_TYPEALIASREF so is_machine_word,
is_pointer, etc. correctly identify aliased builtin types
- viewpoint.c: unfold-and-redispatch in viewpoint_type/upper/lower
- cap.c: unfold in cap_dispatch and modified_cap
- safeto.c: unfold in safe_field_move, safe_to_autorecover, safe_to_move
- typeparam.c: unfold in cap_from_constraint, apply_cap, constraint_cap;
TK_TUPLETYPE fallback for invalid tuple constraints exposed by unfolding
- reify.c: unfold in check_constraints for struct-as-typearg detection
- alias.c: unfold in sendable() only (other alias.c functions keep Phase 1
behavior — compound alias cap handling deferred to follow-up)
Flatten pass:
- constraint_contains_tuple passes unfolded type as both constraint and
scan to fix union member iteration
Lambda/object:
- find_possible_fun_defs: don't free unfolded AST (caller stores pointers)
- catch_up_provides: unfold TK_TYPE alias definitions for ast_passes_type
Array:
- find_possible_element_types and iterator variant: don't free unfolded
AST (caller stores element type pointers)
Reach:
- add_type: unfold-and-redispatch
- trace_kind_append: unfold-and-redispatch
- set_method_types: unfold for param cap extraction
Codegen:
- genname.c, gentrace.c, genmatch.c, gencall.c, genexpr.c: unfold at
all TK_TYPEALIASREF dispatch points
- gentrace.c: unfold in TRACE_MACHINE_WORD case for correct boxed/unboxed
decision on aliased primitive types
Design: #5007
0 commit comments