Skip to content

Decompose 304-line inferType into per-template-kind helpers#207

Merged
ASDAlexander77 merged 1 commit into
mainfrom
refactor/infertype-decomposition
Jul 12, 2026
Merged

Decompose 304-line inferType into per-template-kind helpers#207
ASDAlexander77 merged 1 commit into
mainfrom
refactor/infertype-decomposition

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Third §5 item (giant-method decomposition) from docs/MLIRGen-refactoring-review.md, following the pattern of #205/#206.

inferType was a chain of template-type-kind blocks, each ending in return. Each kind is now a tryInfer* helper returning true when the kind matched and inference was handled, false to continue the chain — which preserves the original fall-through behavior exactly (e.g. a class template whose class info isn't registered falls through, a function template with zero params falls through):

tryInferNamedGenerictryInferClasstryInferInterfacetryInferArraytryInferTuple (tuple/const-tuple field walk shared via a small template helper) → tryInferOptionaltryInferFunctiontryInferUnion.

The conditional-type + typeref tail stays in the driver: the original conditional block intentionally leaves currentTemplateType pointing at the false branch, which the typeref check then examines — that coupling is now spelled out in a comment instead of being an accident of shared mutable locals.

Bodies moved verbatim; the driver reads as a dispatch list with the two-step tail.

Test plan

🤖 Generated with Claude Code

inferType was a chain of template-kind blocks, each ending in return.
Each kind is now a tryInfer* helper returning true when handled:
tryInferNamedGeneric, tryInferClass, tryInferInterface, tryInferArray,
tryInferTuple (shared field walk via template helper), tryInferOptional,
tryInferFunction, tryInferUnion. The conditional-type and typeref tail
stays in the driver because the conditional block intentionally leaves
its false branch for the typeref check. Bodies moved verbatim; driver
is now a readable dispatch list.

Review doc item (section 5).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ASDAlexander77 ASDAlexander77 merged commit 47258ea into main Jul 12, 2026
2 checks passed
@ASDAlexander77 ASDAlexander77 deleted the refactor/infertype-decomposition branch July 12, 2026 12:20
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