skip result use checking in comments

Fixes: https://github.com/dart-lang/sdk/issues/47181

Change-Id: I1761b600d3a8b94551f853896544b64f590af0b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213102
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
pq
2021-09-10 19:13:27 +00:00
committed by commit-bot@chromium.org
parent ce46e99e3d
commit b2eb0c5eb2
2 changed files with 18 additions and 0 deletions
@@ -52,6 +52,11 @@ class UseResultVerifier {
}
void _check(AstNode node, Element element) {
if (node.parent is CommentReference) {
// Don't flag references in comments.
return;
}
var annotation = _getUseResultMetadata(element);
if (annotation == null) {
return;
@@ -765,6 +765,19 @@ void main() {
''');
}
test_topLevelVariable_result_unusedInDoc() async {
// https://github.com/dart-lang/sdk/issues/47181
await assertNoErrorsInCode(r'''
import 'package:meta/meta.dart';
@useResult
int get f => 1;
/// I love [f].
int g = 1;
''');
}
test_topLevelVariable_returned() async {
await assertNoErrorsInCode(r'''
import 'package:meta/meta.dart';