refactor: deduplicate type narrowing and unification bookkeeping - #57
Merged
Conversation
TypeNarrower repeated the same true/false-branch swap pattern in three places and had two near-identical union-unwrapping helpers; MacroExpander independently reimplemented the same union-member lookup logic; TypeSolver had structurally identical CheckCircular branches for UnionType/ IntersectionType and repeated the same unify-bookkeeping pattern across three methods. All consolidated into shared helpers with no behavior change.
Qodana for .NET255 new problems were found
☁️ View the detailed Qodana report Detected 1 dependencyThird-party software listThis page lists the third-party software dependencies used in Loom
Contact Qodana teamContact us at qodana-support@jetbrains.com
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pure readability refactor, no intended behavior change:
TypeNarrowerrepeated the same true/false-branch swap pattern inApplyBinaryNarrowing/NarrowBaseByProperty/NarrowBaseByElement, and had two near-identical union-unwrapping helpers (GetMemberPropertyType/GetMemberElementType) — unified into shared helpers.MacroExpanderindependently reimplemented the same union-member-property-lookup-and-simplify logic found inTypeNarrower— consolidated into a shared utility (moved ontoTypeSimplifier).TypeSolver.CheckCircular'sUnionType/IntersectionTypecases were structurally identical aside from which constructor wraps the result — extracted a shared helper.TypeSolver'sUnifyObjectTypes/UnifyInstantiatedPair/UnifyFunctionTypeseach hand-rolled the same success/updated bookkeeping — consolidated.Test plan
dotnet build— succeeds, no warningsdotnet test— 1778/1778 pass (this is a behavior-preserving refactor, so an unchanged pass count/results is the main signal)Loom.CLIbefore/after — output byte-identical🤖 Generated with Claude Code