Skip to content

[Repo Assist] Refactor: extract mkGenericType helper, eliminate 10-fold SynType.App duplication#275

Merged
7sharp9 merged 1 commit into
masterfrom
repo-assist/fix-issue-274-mksinglearggenerictype-377a8a5f2521512e
Apr 16, 2026
Merged

[Repo Assist] Refactor: extract mkGenericType helper, eliminate 10-fold SynType.App duplication#275
7sharp9 merged 1 commit into
masterfrom
repo-assist/fix-issue-274-mksinglearggenerictype-377a8a5f2521512e

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Closes #274

Adds a private mkGenericType helper in AstExtensions.fs that consolidates the repeated SynType.App construction pattern across 10 extension members (Option, ResizeArray, Set, NativePointer, Option(string), Dictionary, Map, List(SynType), Array, List(string)).

Root Cause

Ten SynType with extension members each inlined an identical 8–10 line SynType.App(...) call with the same boilerplate arguments, resulting in ~100 lines of near-identical structural duplication. A SynType.CreateApp helper already existed (line 195) but used dotsOrCommas args for commaRanges and Some range0 for both angle ranges — incompatible with the postfix Array member which intentionally uses greaterRange=None; lessRange=None.

Fix

Added to AstExtensions.fs (module-level, alongside the existing dotsOrCommas private helper):

/// Builds a generic SynType.App node. Use hasAngles=false only for postfix array syntax.
let private mkGenericType (typeName: SynType) (typeArgs: SynType list) (isPostfix: bool) (hasAngles: bool) =
    SynType.App(
        typeName = typeName,
        typeArgs = typeArgs,
        commaRanges = [],
        isPostfix = isPostfix,
        range = range0,
        greaterRange = (if hasAngles then Some range0 else None),
        lessRange  = (if hasAngles then Some range0 else None)
    )

All 10 call sites replaced with one-liners using mkGenericType.

Trade-offs

  • Benefit: single source of truth for commaRanges = [] default and angle-bracket convention; Array's intentional no-angle-bracket exception is now explicit via hasAngles=false rather than hiding in copy-pasted code; ~90 lines of boilerplate removed.
  • Risk: none — semantics are identical at all 10 call sites; commaRanges = [] was already consistent across all of them.

Test Status

✅ Build succeeded (0 warnings, 0 errors)
✅ 33/33 integration tests passed

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@ee49512da7887942965ac0a0e48357106313c9dd. View source at https://github.com/githubnext/agentics/tree/ee49512da7887942965ac0a0e48357106313c9dd/workflows/repo-assist.md.

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@ee49512da7887942965ac0a0e48357106313c9dd. View source at https://github.com/githubnext/agentics/tree/ee49512da7887942965ac0a0e48357106313c9dd/workflows/repo-assist.md.

… 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>
@7sharp9 7sharp9 marked this pull request as ready for review April 16, 2026 12:38
Copilot AI review requested due to automatic review settings April 16, 2026 12:38
@7sharp9 7sharp9 merged commit 8d18acb into master Apr 16, 2026
@7sharp9 7sharp9 deleted the repo-assist/fix-issue-274-mksinglearggenerictype-377a8a5f2521512e branch April 16, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mkGenericType helper that centralizes SynType.App construction defaults (notably commaRanges=[] and configurable angle bracket ranges).
  • Updated the 10 SynType extension members (e.g., Option, List, Map, Dictionary, Array) to delegate to mkGenericType, eliminating repeated inline SynType.App(...) blocks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate Code: Repeated SynType.App boilerplate in AstExtensions.fs

2 participants