Skip to content

Add regression test for comment preservation in func-to-computed-property refactoring#3362

Merged
ahoppen merged 1 commit into
swiftlang:mainfrom
nenadvulic:fix-3236-preserve-comment
Jun 15, 2026
Merged

Add regression test for comment preservation in func-to-computed-property refactoring#3362
ahoppen merged 1 commit into
swiftlang:mainfrom
nenadvulic:fix-3236-preserve-comment

Conversation

@nenadvulic

Copy link
Copy Markdown
Contributor

Refs #3236.

#3236 reports that ConvertZeroParameterFunctionToComputedProperty drops a leading comment (e.g. a doc comment) when converting a zero-parameter function to a computed property.

I couldn't reproduce this on main: the refactoring already preserves the converted declaration's leading trivia. The binding specifier is derived from the detached funcKeyword (which keeps its leading trivia), and attributes/modifiers are carried over — so the comment survives whether it sits on the func keyword, a modifier, or an attribute.

This adds a regression test (testRefactoringFunctionToComputedPropertyPreservesLeadingComment) so the behavior stays correct, covering:

  • a /// doc comment with no modifiers,
  • a /// comment with a modifier (public),
  • a /// comment with an attribute (@inlinable),
  • a /** */ block comment.

All pass on main. Given this, #3236 looks resolved and could be closed once this lands (or if someone has a precise case that still drops the comment, the test is a good place to add it).

…ed-property refactoring

ConvertZeroParameterFunctionToComputedProperty already preserves the
leading trivia (e.g. a doc comment) of the converted declaration, since
the binding specifier is derived from the detached funcKeyword and the
attributes/modifiers are carried over. Add a regression test covering a
doc comment with no modifiers, a modifier, an attribute, and a block
comment, so the behavior reported in swiftlang#3236 stays correct.

Refs swiftlang#3236.
@ahoppen

ahoppen commented Jun 11, 2026

Copy link
Copy Markdown
Member

@swift-ci Please test

@ahoppen

ahoppen commented Jun 11, 2026

Copy link
Copy Markdown
Member

Thanks, @nenadvulic.

@nenadvulic

Copy link
Copy Markdown
Contributor Author

@ahoppen The two CI failures look unrelated to this change 😞

  • Swift Test Windows Platform (Jenkins): the build failed during Get-Dependencies, before compiling anything — the dependency server returned an HTTP 500 (Exception calling "DownloadFile" ... (500) Internal Server Error). The
    GitHub Actions Windows jobs (5.9 through nightly-main) and Run tests using swift-syntax-dev-utils (Windows) all pass.

  • Test / Swift SDK for Wasm Build (nightly-main - jammy): crashes with Error: Trap: out of bounds memory access in the XCTest runtime using swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a. The same job fails on other recent PRs too
    (e.g. Allow trailing commas in macro role attribute arguments #3361, which only touches CODEOWNERS), so it looks like a pre-existing nightly-main toolchain issue. The Wasm jobs on 6.2 and nightly-6.3 pass.

All the jobs that actually run the new test are green.

@ahoppen

ahoppen commented Jun 15, 2026

Copy link
Copy Markdown
Member

Yeah, the failure are unrelated. Let me trigger CI again.

@swift-ci Please test Windows

@ahoppen ahoppen merged commit bd09469 into swiftlang:main Jun 15, 2026
37 of 38 checks passed
@nenadvulic nenadvulic deleted the fix-3236-preserve-comment branch June 18, 2026 22:19
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.

2 participants