[Repo Assist] Refactor: extract mkGenericType helper, eliminate 10-fold SynType.App duplication#275
Merged
7sharp9 merged 1 commit intoApr 16, 2026
Conversation
… duplication Adds a private `mkGenericType` helper in AstExtensions.fs that consolidates the repeated `SynType.App` construction pattern across 10 extension members. Reduces ~100 lines of near-identical boilerplate to ~20 lines. The `Array` member's intentional `greaterRange=None; lessRange=None` (postfix syntax without angles) is now explicit via the `hasAngles` parameter rather than hidden in copy-pasted code. Closes #274 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
23 tasks
There was a problem hiding this comment.
Pull request overview
Refactors AstExtensions to reduce duplicated SynType.App boilerplate by introducing a shared helper for constructing generic SynType application nodes, while preserving the existing special-case behavior for postfix array syntax.
Changes:
- Added a private
mkGenericTypehelper that centralizesSynType.Appconstruction defaults (notablycommaRanges=[]and configurable angle bracket ranges). - Updated the 10
SynTypeextension members (e.g.,Option,List,Map,Dictionary,Array) to delegate tomkGenericType, eliminating repeated inlineSynType.App(...)blocks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Closes #274
Adds a private
mkGenericTypehelper inAstExtensions.fsthat consolidates the repeatedSynType.Appconstruction pattern across 10 extension members (Option,ResizeArray,Set,NativePointer,Option(string),Dictionary,Map,List(SynType),Array,List(string)).Root Cause
Ten
SynType withextension members each inlined an identical 8–10 lineSynType.App(...)call with the same boilerplate arguments, resulting in ~100 lines of near-identical structural duplication. ASynType.CreateApphelper already existed (line 195) but useddotsOrCommas argsforcommaRangesandSome range0for both angle ranges — incompatible with the postfixArraymember which intentionally usesgreaterRange=None; lessRange=None.Fix
Added to
AstExtensions.fs(module-level, alongside the existingdotsOrCommasprivate helper):All 10 call sites replaced with one-liners using
mkGenericType.Trade-offs
commaRanges = []default and angle-bracket convention;Array's intentional no-angle-bracket exception is now explicit viahasAngles=falserather than hiding in copy-pasted code; ~90 lines of boilerplate removed.commaRanges = []was already consistent across all of them.Test Status
✅ Build succeeded (0 warnings, 0 errors)
✅ 33/33 integration tests passed