Skip to content

Add inline function refactoring#3318

Open
Padmashree06 wants to merge 1 commit intoswiftlang:mainfrom
Padmashree06:function-Inlining-keep-original
Open

Add inline function refactoring#3318
Padmashree06 wants to merge 1 commit intoswiftlang:mainfrom
Padmashree06:function-Inlining-keep-original

Conversation

@Padmashree06
Copy link
Copy Markdown
Contributor

Explanation:

Add refactoring to inline function at function call.

  1. If the function body consists of a single return statement, the returned expression is inlined directly.
  2. For multi-statement or void functions, the body is wrapped in a closure and invoked.
  3. Function parameters are replaced by arguments provided at function call.

Test cases are written for the same.

Scope:

This will provide refactoring to inline functions at function call and will be wired as a codeAction in sourcekit-lsp.

Issues:

swiftlang/sourcekit-lsp#2508

Original PRs:

Not Applicable

Risk:

This is a standalone feature and does not change the existing structure or functionality of the code.
It is a additional feature.

Testing:

Added unit tests covering:

  • Simple return expression inlining
  • Multiple parameters
  • Multi-statement functions (closure wrapping)
  • Void functions
  • Failure cases (missing function, argument mismatch, method calls)

All tests pass locally using swift test.

Reviewers:

Not Applicable

@Padmashree06 Padmashree06 requested a review from a team as a code owner April 15, 2026 21:35
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