Skip to content

Commit 0733438

Browse files
FMorschelCommit Queue
authored andcommitted
[DAS] Fixes false-positive on comment references for unnecessary_underscores
Fixes: #61558 Change-Id: I813e4390521c31660776b12c6cd0792f779ff675 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464627 Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 8b37db6 commit 0733438

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pkg/linter/lib/src/rules/unnecessary_underscores.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ class _Visitor extends SimpleAstVisitor<void> {
5656

5757
@override
5858
void visitFormalParameterList(FormalParameterList node) {
59-
late Set<Element> referencedElements = collectReferences(node.parent);
59+
late Set<Element> referencedElements = {
60+
...collectReferences(node.parent),
61+
if (node.parent?.parent case FunctionDeclaration(
62+
:var documentationComment,
63+
))
64+
...collectReferences(documentationComment),
65+
};
6066

6167
for (var parameter in node.parameters) {
6268
var parameterName = parameter.name;

pkg/linter/test/rules/unnecessary_underscores_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ class UnnecessaryUnderscoresTest extends LintRuleTest {
1717
@override
1818
String get lintRule => 'unnecessary_underscores';
1919

20+
test_commentReferenceFunction() async {
21+
await assertNoDiagnostics('''
22+
/// This is a reference to [__].
23+
void f(int __) {}
24+
''');
25+
}
26+
27+
test_commentReferenceMethod() async {
28+
await assertNoDiagnostics('''
29+
class C {
30+
/// This is a reference to [__].
31+
void m(int __) {}
32+
}
33+
''');
34+
}
35+
2036
test_enum_field_unused() async {
2137
await assertNoDiagnostics(r'''
2238
enum E {

0 commit comments

Comments
 (0)