| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
bool canReuseClassTypeArguments(List<ast.DartType> types) {Maybe something like this is easier to read?
```
enum TypeParametersReuse {
function, class, none
}
TypeParametersReuse computeTypeParametersReuse(List<ast.DartType> types) {
final type = types[0];
if (type is! ast.TypeParameterType || type.nullability == .nullable) {
return .none;
}
final decl = type.parameter.declaration;
if (types.length > decl.typeParameters.length) {
return .none;
}
for (int i = 1; i < types.length; ++i) {
final type = types[i];
if (type is! ast.TypeParameterType || type.nullability == .nullable || type.parameter != decl.typeParameters[i]) {
return .none;
}
}
if (decl is ast.Class) {
if (getNumberOfInstantiatorTypeArguments(cls) != cls.typeParameters.length) {
return .none;
}
return .class;
} else if (decl is ast.Procedure) {
return .function;
}
return .none;
}
```| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
bool canReuseClassTypeArguments(List<ast.DartType> types) {Maybe something like this is easier to read?
```
enum TypeParametersReuse {
function, class, none
}TypeParametersReuse computeTypeParametersReuse(List<ast.DartType> types) {
final type = types[0];
if (type is! ast.TypeParameterType || type.nullability == .nullable) {
return .none;
}
final decl = type.parameter.declaration;
if (types.length > decl.typeParameters.length) {
return .none;
}
for (int i = 1; i < types.length; ++i) {
final type = types[i];
if (type is! ast.TypeParameterType || type.nullability == .nullable || type.parameter != decl.typeParameters[i]) {
return .none;
}
}
if (decl is ast.Class) {
if (getNumberOfInstantiatorTypeArguments(cls) != cls.typeParameters.length) {
return .none;
}
return .class;
} else if (decl is ast.Procedure) {
return .function;
}
return .none;
}
```
Thank you for the suggestion!
I merged both predicates to a single function with enum result as you suggested. While doing this, I realized that we can reuse instantiator (class) type arguments in more cases, so I changed the logic accordingly and extracted `_isPrefixOf` helper.
Please take a look once again.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |