Skip to content

Commit 5388a2a

Browse files
pqpull[bot]
authored andcommitted
[wildcards] UNUSED_FIELD tests
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 <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent b0d5a62 commit 5388a2a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pkg/analyzer/test/src/diagnostics/unused_field_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,29 @@ class A {
288288
]);
289289
}
290290

291+
test_notUsed_noReference_wildcard() async {
292+
await assertErrorsInCode(r'''
293+
class A {
294+
int _ = 0;
295+
}
296+
''', [
297+
error(WarningCode.UNUSED_FIELD, 16, 1),
298+
]);
299+
}
300+
301+
test_notUsed_noReference_wildcard_preWildcards() async {
302+
await assertErrorsInCode(r'''
303+
// @dart = 3.4
304+
// (pre wildcard-variables)
305+
306+
class A {
307+
int _ = 0;
308+
}
309+
''', [
310+
error(WarningCode.UNUSED_FIELD, 60, 1),
311+
]);
312+
}
313+
291314
test_notUsed_nullAssign() async {
292315
await assertNoErrorsInCode(r'''
293316
class A {

0 commit comments

Comments
 (0)