Skip to content

Commit

Permalink
Consider nested TypeNames when counting uses. (dart-lang#1857)
Browse files Browse the repository at this point in the history
Child TypeNames in the AST being ignored due
to missing call to super results in false
positives in cases such as type arguments.
  • Loading branch information
emerssso authored and pq committed Dec 2, 2019
1 parent 345c31d commit ed31be8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/rules/avoid_private_typedef_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class _CountVisitor extends RecursiveAstVisitor {
@override
visitTypeName(TypeName node) {
if (node.name.name == type) count++;
super.visitTypeName(node);
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/rules/avoid_private_typedef_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ _F5 v5b;
typedef void _F6(); // OK
_F6 f6a() => null;
_F6 f6b() => null;

typedef _F7 = void Function(); // OK
m7(_F7 f) => null;
List<_F7> l7 = [];

typedef void _F8(); // OK
m8(_F8 f) => null;
List<_F8> l8 = [];

0 comments on commit ed31be8

Please sign in to comment.