avoid_shadowing_type_parameters
The type parameter '{0}' shadows a type parameter from the enclosing {1}.
Description
#The analyzer produces this diagnostic when a type parameter shadows a type parameter from an enclosing declaration.
Shadowing a type parameter with a different type parameter can lead to subtle bugs that are difficult to debug.
Example
#The following code produces this diagnostic because the type parameter T
defined by the method m
shadows the type parameter T
defined by the
class C
:
dart
class C<T> {
void m<T>() {}
}
Common fixes
#Rename one of the type parameters:
dart
class C<T> {
void m<S>() {}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。