Skip to content

refactor: deduplicate type narrowing and unification bookkeeping - #57

Merged
R-unic merged 1 commit into
masterfrom
refactor/type-narrowing-dedup
Jul 24, 2026
Merged

refactor: deduplicate type narrowing and unification bookkeeping#57
R-unic merged 1 commit into
masterfrom
refactor/type-narrowing-dedup

Conversation

@R-unic

@R-unic R-unic commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Pure readability refactor, no intended behavior change:

  • TypeNarrower repeated the same true/false-branch swap pattern in ApplyBinaryNarrowing/NarrowBaseByProperty/NarrowBaseByElement, and had two near-identical union-unwrapping helpers (GetMemberPropertyType/GetMemberElementType) — unified into shared helpers.
  • MacroExpander independently reimplemented the same union-member-property-lookup-and-simplify logic found in TypeNarrower — consolidated into a shared utility (moved onto TypeSimplifier).
  • TypeSolver.CheckCircular's UnionType/IntersectionType cases were structurally identical aside from which constructor wraps the result — extracted a shared helper.
  • TypeSolver's UnifyObjectTypes/UnifyInstantiatedPair/UnifyFunctionTypes each hand-rolled the same success/updated bookkeeping — consolidated.

Test plan

  • dotnet build — succeeds, no warnings
  • dotnet test — 1778/1778 pass (this is a behavior-preserving refactor, so an unchanged pass count/results is the main signal)
  • Compiled the same input through Loom.CLI before/after — output byte-identical

🤖 Generated with Claude Code

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.
@github-actions

Copy link
Copy Markdown

Qodana for .NET

255 new problems were found

Inspection name Severity Problems
Auto-property accessor is never used (private accessibility) 🔶 Warning 6
Redundant using directive 🔶 Warning 5
Auto-property accessor is never used (non-private accessibility) 🔶 Warning 5
Non-accessed positional property (non-private accessibility) 🔶 Warning 4
Redundant argument with default value 🔶 Warning 2
'??' condition is never null according to nullable reference types' annotations 🔶 Warning 1
Redundant name qualifier 🔶 Warning 1
Redundant nullable warning suppression expression 🔶 Warning 1
Type member is never used (private accessibility) 🔶 Warning 1
Unused parameter (private accessibility) 🔶 Warning 1
Unused local variable 🔶 Warning 1
Type member is never used (non-private accessibility) ◽️ Notice 93
Use preferred style of 'new' expression when created type is not evident ◽️ Notice 83
Member can be made private (non-private accessibility) ◽️ Notice 18
Class is never instantiated (non-private accessibility) ◽️ Notice 4
Some values of the enum are not processed inside 'switch' statement ◽️ Notice 4
Auto-property can be made get-only (non-private accessibility) ◽️ Notice 3
Invert 'if' statement to reduce nesting ◽️ Notice 3
RoslynAnalyzers The member referenced by the MemberData attribute returns untyped data rows ◽️ Notice 3
Use preferred style for trailing comma before new line in multiline lists ◽️ Notice 2
RoslynAnalyzers Do not use Enumerable methods on indexable collections ◽️ Notice 2
Remove redundant parentheses ◽️ Notice 1
Auto-property can be made get-only (private accessibility) ◽️ Notice 1
RoslynAnalyzers Use concrete types when possible for improved performance ◽️ Notice 1
Foreach loop can be converted into LINQ-expression but another 'GetEnumerator' method will be used ◽️ Notice 1
Merge null/pattern checks into complex pattern ◽️ Notice 1
Redundant string interpolation ◽️ Notice 1
Replace with 'field' keyword ◽️ Notice 1
Some values of the enum are not processed inside 'switch' statement and are handled via default section ◽️ Notice 1
Tail recursive call can be replaced with loop ◽️ Notice 1
Type member is never accessed via base type (non-private accessibility) ◽️ Notice 1
Method return value is never used (non-private accessibility) ◽️ Notice 1
Literal length can be reduced by using verbatim string ◽️ Notice 1

☁️ View the detailed Qodana report

Detected 1 dependency

Third-party software list

This page lists the third-party software dependencies used in Loom

Dependency Version Licenses
Tomlyn 2.6.0 BSD-2-Clause
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@R-unic
R-unic merged commit d0ec919 into master Jul 24, 2026
1 of 2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Loom Release 1.0.0 Jul 24, 2026
@R-unic
R-unic deleted the refactor/type-narrowing-dedup branch July 24, 2026 08:48
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