Skip to content

Commit

Permalink
[wildcards] UNUSED_FIELD tests
Browse files Browse the repository at this point in the history
Since `_` fields are binding, I think we want to treat `_`s like any other private field and report `UNUSED_FIELD`s accordingly.

These tests confirm that our current implementation is WAI.

Fixes: #55862

Change-Id: I2c8486a3b9e55d22c53989d74de974334477ec33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373405
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
pq authored and Commit Queue committed Jun 27, 2024
1 parent 8ed1ce9 commit d45b528
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/analyzer/test/src/diagnostics/unused_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,29 @@ class A {
]);
}

test_notUsed_noReference_wildcard() async {
await assertErrorsInCode(r'''
class A {
int _ = 0;
}
''', [
error(WarningCode.UNUSED_FIELD, 16, 1),
]);
}

test_notUsed_noReference_wildcard_preWildcards() async {
await assertErrorsInCode(r'''
// @dart = 3.4
// (pre wildcard-variables)
class A {
int _ = 0;
}
''', [
error(WarningCode.UNUSED_FIELD, 60, 1),
]);
}

test_notUsed_nullAssign() async {
await assertNoErrorsInCode(r'''
class A {
Expand Down

0 comments on commit d45b528

Please sign in to comment.