-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
The lint avoid_types_as_parameter_names does not seem to consider a type variable as a type:
void g<X>(int X) {} // No lint.
class C<X> {
C.name();
factory C(X) => C.name(); // No lint.
void m(void Function(C X) h) {} // No lint.
}It seems equally relevant to flag type parameter names and other type names: In both cases, the shadowing makes nested code harder to read, so I would expect a lint message at all the comments above. The third one doesn't really hurt anybody, because that X is not in scope for any term, but it is likely that the use of a type variable in that kind of position would arise because the author wanted to write something else.
Another issue with this lint is the documentation: https://dart-lang.github.io/linter/lints/avoid_types_as_parameter_names.html.
On that page the BAD example m(f(int)); is given, but that could very well be an invocation of a function m with an actual argument f(int), and that doesn't involve any formal parameters whose name is a type name at all. Maybe the example could be something like void m(int) {} which is unambiguously a function declaration, and then the GOOD example could be void m(int i) {}?