Skip to content

Unified: Handle additionalTrailingClosures for more expression kinds - #22785

Merged
paldepind merged 5 commits into
mainfrom
unified/swift-extractions-improvements
Oct 8, 2026
Merged

paldepind merged 5 commits into
mainfrom
unified/swift-extractions-improvements

Conversation

@paldepind

Copy link
Copy Markdown
Contributor

With this PR we handle additionalTrailingClosures for all expression kinds that have the fields (except macroExpansionDecl which we don't extract).

Before that we unify two cases for functionCallExpr which I think fixes a problem where the callee was handled differently for calls that had a trailing closure.

trailing closure

Previously the callee was handled differently depending on whether the
call had a trailing closure. This merges the two rules for
`functionCallExpr` into one to erase the difference.
@paldepind
paldepind marked this pull request as ready for review October 8, 2026 12:31
@paldepind
paldepind requested a review from a team as a code owner October 8, 2026 12:31
Copilot AI balanced review requested due to automatic review settings October 8, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The specialized array-constructor mapping lacks direct coverage for its new additional-trailing-closure behavior.

1 open finding
What changed in this PR

Extends Swift unified AST translation to preserve additional trailing closures across function, macro, and subscript expressions.

Changes:

  • Unifies function-call handling and normalizes callee translation.
  • Maps trailing closures for function and subscript calls.
  • Adds Swift corpus coverage and generated expectations.
File Description
unified/​extractor/​src/​languages/​swift/​swift.rs Extends trailing-closure translation rules.
unified/​extractor/​tests/​corpus/​swift/​functions/​function-call.swift Tests multiple function-call trailing closures.
unified/​extractor/​tests/​corpus/​swift/​functions/​function-call.output Records generated function-call AST output.
unified/​extractor/​tests/​corpus/​swift/​expressions/​subscript-call.swift Tests subscript calls with trailing closures.
unified/​extractor/​tests/​corpus/​swift/​expressions/​subscript-call.output Records generated subscript-call AST output.
unified/​extractor/​tests/​corpus/​swift/​control-flow/​nested-enum-case-pattern.swift Tests trailing-closure calls in expression patterns.
unified/​extractor/​tests/​corpus/​swift/​control-flow/​nested-enum-case-pattern.output Records generated pattern AST output.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

arguments: _* @args
trailingClosure: @tc)
trailingClosure: @tc
additionalTrailingClosures: _* @additional)
asgerf
asgerf previously approved these changes Oct 8, 2026
@paldepind

Copy link
Copy Markdown
Contributor Author

Ready for re-review. Nothing substantially changed, I only expanded on a test at the behest of Copilot.

@paldepind
paldepind merged commit 8436a8b into main Oct 8, 2026
9 checks passed
@paldepind
paldepind deleted the unified/swift-extractions-improvements branch October 8, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants