Skip to content

FIX #56335 [Augmentations] Analyzer doesn't support augmenting functions with empty bodies #62940

Open
Darkildo wants to merge 2 commits intodart-lang:mainfrom
Darkildo:Analyzer-doesn't-support-augmenting-functions-with-empty-bodies
Open

FIX #56335 [Augmentations] Analyzer doesn't support augmenting functions with empty bodies #62940
Darkildo wants to merge 2 commits intodart-lang:mainfrom
Darkildo:Analyzer-doesn't-support-augmenting-functions-with-empty-bodies

Conversation

@Darkildo
Copy link
Copy Markdown
Contributor

This PR fixes analyzer handling for augmenting functions with empty bodies.

According to the augmentation specification, an augmenting function declaration may use an empty body (;) to augment only metadata or documentation comments, without changing the body of the augmented member. In analyzer, this currently led to a false positive on code like:

class C {
  void foo() {}
}

augment class C {
  augment void foo();
}

The root cause was that the analyzer scanner only enabled augmentation-library scanning when Feature.macros was enabled. That caused augmentation syntax to be scanned incorrectly unless macros were enabled, which then cascaded into bogus parse/analysis errors, including CONCRETE_CLASS_WITH_ABSTRACT_MEMBER.

This change updates the scanner to use Feature.augmentations for forAugmentationLibrary, which matches the feature actually being tested, and adds a regression test to verify that an empty-body augmenting method no longer reports an error.

Fix #56335

@copybara-service
Copy link
Copy Markdown

Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at:

https://dart-review.googlesource.com/c/sdk/+/489520

Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly.

Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR).

@copybara-service
Copy link
Copy Markdown

Gerrit CL has build or test failures, please review them in Gerrit and fix them before requesting another review.

@copybara-service
Copy link
Copy Markdown

CL has new comments, please view and respond to them in Gerrit.

If a reviewer requested changes, push new commits to this PR and it will be automatically copied to Gerrit. After that you can mark reviewer comments as resolved in Gerrit and request another round of reviews.

Note: when you add comments in Gerrit they only become visible after you send them by clicking Reply and Send.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/489520 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

CL has new comments, please view and respond to them in Gerrit.

If a reviewer requested changes, push new commits to this PR and it will be automatically copied to Gerrit. After that you can mark reviewer comments as resolved in Gerrit and request another round of reviews.

Note: when you add comments in Gerrit they only become visible after you send them by clicking Reply and Send.

@copybara-service
Copy link
Copy Markdown

https://dart-review.googlesource.com/c/sdk/+/489520 has been updated with the latest commits from this pull request.

@copybara-service
Copy link
Copy Markdown

CL has new comments, please view and respond to them in Gerrit.

If a reviewer requested changes, push new commits to this PR and it will be automatically copied to Gerrit. After that you can mark reviewer comments as resolved in Gerrit and request another round of reviews.

Note: when you add comments in Gerrit they only become visible after you send them by clicking Reply and Send.

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.

[Augmentations] Analyzer doesn't support augmenting functions with empty bodies

1 participant