Skip to content

Commit d9731ac

Browse files
pqCommit Queue
authored and
Commit Queue
committed
fix prefer_void_to_null false positive on extension type representations
Fixes: https://github.com/dart-lang/linter/issues/4720 Change-Id: Ie3a736cbd4d190135eb77932ec8ba9352683226e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330200 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 985c292 commit d9731ac

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ class _Visitor extends SimpleAstVisitor<void> {
142142
return;
143143
}
144144

145+
// extension type N(Null _) ...
146+
if (parent is RepresentationDeclaration) {
147+
return;
148+
}
149+
145150
// https://github.com/dart-lang/linter/issues/2792
146151
if (parent is MethodDeclaration &&
147152
isVoidIncompatibleOverride(parent, node)) {

pkg/linter/test/rules/prefer_void_to_null_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ void f(int a) {
3939
]);
4040
}
4141

42+
/// https://github.com/dart-lang/linter/issues/4759
43+
test_extensionTypeRepresentation() async {
44+
await assertNoDiagnostics(r'''
45+
extension type B<T>(T? _) {}
46+
extension type N(Null _) implements B<Never> {}
47+
''');
48+
}
49+
4250
test_localVariable() async {
4351
await assertNoDiagnostics(r'''
4452
void f() {

0 commit comments

Comments
 (0)