avoid-generics-shadowing
preset: recommended
Warns when a generic type shadows and existing top-level (class, mixin, typedef or enum) declaration.
Shadowing existing declarations can be extremely confusing when it comes to parameters or variables annotated with a generic type that looks close to a class name.
Example
❌ Bad:
class SomeClass {
void method<MyEnum>(MyEnum p) {} // LINT
AnotherClass anotherMethod<AnotherClass>() {} // LINT
}
class AnotherClass {}
enum MyEnum { first }
✅ Good:
class SomeClass {
void method<T>(T p) {}
R anotherMethod<R>() {}
}
class AnotherClass {}
enum MyEnum { first }