FIX #56335 [Augmentations] Analyzer doesn't support augmenting functions with empty bodies #62940
Conversation
|
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). |
|
Gerrit CL has build or test failures, please review them in Gerrit and fix them before requesting another review. |
|
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. |
|
https://dart-review.googlesource.com/c/sdk/+/489520 has been updated with the latest commits from this pull request. |
|
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. |
|
https://dart-review.googlesource.com/c/sdk/+/489520 has been updated with the latest commits from this pull request. |
|
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. |
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: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