Skip to content

[ARCHIVE] Typed-expression AST infrastructure (saved for future revival) - #3

Closed
milyin wants to merge 3 commits into
mainfrom
backup/before-cleanup
Closed

[ARCHIVE] Typed-expression AST infrastructure (saved for future revival)#3
milyin wants to merge 3 commits into
mainfrom
backup/before-cleanup

Conversation

@milyin

@milyin milyin commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Purpose — preservation, not merge

This PR archives the typed-expression AST infrastructure so it is not lost when PR #2 (cleanup/remove-unused-ast-infrastructure) deletes it from main.

It is intentionally not meant to be merged as-is — mergeability and CI are not a concern. It exists as a durable, reviewable reference so the AST work can be revived later when an emitter is ready to build typed trees instead of raw KtCode strings.

Note: while PR #2 is still open, the diff below is small (main currently still contains the AST). Once PR #2 merges into main, this PR's diff will automatically expand to show the full AST infrastructure as a re-addable set of changes.

What this branch preserves

The complete expr module and its integration points:

  • ExprArena — ownership/provenance tracker for expression binders. Allocates BindingIds per-arena; graft alpha-remaps when composing trees from different arenas, making variable capture structurally impossible.
  • KtExpr / KtStmt / KtLambda / KtLiteral / KtPattern — the typed Kotlin expression/statement AST.
  • BindingId / ArenaId / Binder / Spelling / NameHint — binder identity and rendering-name machinery (Fixed for API-surface parameter names, Fresh for renderer-allocated locals).
  • Tree operationsfill_hole, substitute, free_names, has_hole.
  • Slot bridgesExprSlot<T>, Ast<T>, AnnotationSlot, KtAnnotation, StaticAnnotationText, KtAccessor, AccessorTree, and KtFun::typed_body — the exclusive Legacy(text) vs Ast(tree) sums that let declarations carry either raw text or typed trees.
  • The full internal test suite for the above (arena provenance, alpha-renaming, capture-avoidance, etc.).

Why it was removed from the mainline

No emitter (prebindgen-jni or any other consumer) constructs typed trees yet — the entire tier was #[allow(dead_code)] infrastructure staged ahead of its consumers. PR #2 removes it to keep the shipping public API minimal. This archive keeps the design and its tests recoverable.

Also included

  • Commit 598e19d — validate function overloads by parameter-type lists in merge_files (independent of the AST work).

How to revive

Branch from here (or cherry-pick the expr module back) once a code generator is ready to emit typed expression trees, then re-wire the ExprSlot/AnnotationSlot/KtAccessor bridges into the model.

@milyin

milyin commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #4. This branch's PR diff didn't show the AST because GitHub diffs against the merge-base, which already contained it. #4 restores the AST on top of current (AST-free) main so the full infrastructure is visible as an additive diff. The raw pre-cleanup source remains preserved on branch backup/before-cleanup.

@milyin milyin closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant