Skip to content

[AST] don't break a doc comment with a regular comment #66136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2023

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://95307936

When a declaration has a regular comment between its doc comment and the declaration itself, that doc comment is lost:

/// This is documentation
// This is a comment
public func myFunc() {}

This PR changes the comment attachment rules to skip over ordinary comments instead of using them to break them apart like a blank line would.

Notably, this change surfaced a bug in the standard library documentation: The default implementation of the != operator in Equatable had a regular comment between the doc comment and the declaration, causing that documentation to be lost. (This is why i had to update the tests in test/SourceKit/DocSupport, because the documentation for != started showing up!)

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me, thanks @QuietMisdreavus! I don't think I had any good reason for not doing this in 22f5983, probably just went with keeping the current behavior assuming there was a good reason for it.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thank you. Makes sense to me

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus QuietMisdreavus merged commit 60ef958 into main May 30, 2023
@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus/comment-attachment branch May 30, 2023 14:44
meg-gupta pushed a commit to meg-gupta/swift that referenced this pull request Jun 2, 2023
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.

3 participants