Open
Description
Given a file containing the following:
Future<void> f(ChangeBuilder builder) async {
var changeBuilder = builder as ChangeBuilderImpl;
int computeChangeHash() => changeBuilder.changeHash;
computeChangeHash();
}
class ChangeBuilder {}
class ChangeBuilderImpl implements ChangeBuilder {
int get changeHash => 0;
}
Select the name of the local function computeChangeHash
and invoke the "Inline Method" assist. The result will be
Future<void> f(ChangeBuilder builder) async {
var changeBuilder = builder as ChangeBuilderImpl;
changeBuilder2.changeHash;
}
class ChangeBuilder {}
class ChangeBuilderImpl implements ChangeBuilder {
int get changeHash => 0;
}
The reference to the local variable changeBuilder
is erroneously changed to changeBuilder2
.
I suspect that this is because the assist doesn't know that the "method" being inlined is a local function and that local variables from outside the function are still valid to reference.
We probably need an "Inline Local Function" variant that knows what's being inlined. It will still need to be aware of the possibility of shadowing.