sdk
sdk copied to clipboard
Renaming a named parameter in a function type ignores uses in argument lists
Given the following:
void g(int Function({int x}) f) {
f(x: 2);
}
If you rename the x in the parameter list to y you get:
void g(int Function({int y}) f) {
f(x: 2); // error
}
It would be nice if it could find references within the body of the method and rename them.
Similarly for the following case:
typedef IntToInt = int Function({int x});
void g(IntToInt f) {
f(x: 2);
}
The problem is that function types are structural, they don't track provenance. Sometimes if is the same FunctionType instance, and so we could know that it is the same ParameterElement. But if we instantiated a generic FunctionType, or used LUB of two FunctionTypes, everything is lost in the history.
void f(
void Function({int? aaa, int? bbb})? a,
void Function({int? bbb, int? ccc}) b,
) {
(a ?? b)(bbb: 0);
}
Here, for example, we get only bbb as the shared parameter of a ?? b. And theoretically we would need to rename it in both a and b types.