sdk
sdk copied to clipboard
Renaming field doesn't update constructors on subclasses of subclasses
Repro:
class Base {
Base({required this.propriety});
String propriety;
}
class Second extends Base {
Second({required super.propriety});
}
class Third extends Second {
Third({required super.propriety});
}
If you rename propriety to newName:
class Base {
Base({required this.newName});
String newName;
}
class Second extends Base {
Second({required super.newName});
}
class Third extends Second {
Third({required super.propriety}); // implicit_super_initializer_missing_arguments + super_formal_parameter_without_associated_named
}
I'll take a look at this
Renaming a field to private also misses some cases:
class Base {
Base(this.propriety)
: assert(propriety.isNotEmpty, 'Propriety cannot be empty'),
length = propriety.length {
propriety;
}
String propriety;
int length;
}
Becomes:
class Base {
Base(this._propriety)
: assert(propriety.isNotEmpty, 'Propriety cannot be empty'), // missing rename
length = propriety.length { // missing rename
_propriety;
}
String _propriety;
int length;
}
Since this might be an easy fix (overlooked case), I'll see if I can work on this together. If I find it too difficult, I'll open a new issue for it.
I think this has been fixed with https://github.com/dart-lang/sdk/issues/61194. Can you confirm @fshcheglov or @scheglov? Maybe we can leave this open for the comment above. I can test this out later when I update my master version.
I took a look at it, and my change only works when renaming FormalParameterElement, while in this issue the example is about renaming FieldElement, which has references to formal parameters but is itself not a formal parameter. So - we need some additional enhancements to field rename refactoring here.
How do you want to proceed? Should I enhance field rename refactoring, or do you want to pick this up from here?
I had some trouble when I was originally looking at this, so you'll probably be faster than me. If you have the time and would like to, feel free to do so.
I'm currently working on some other issues, so it would take me some time to revisit this and understand where I left of or to start from scratch either way.
https://dart-review.googlesource.com/c/sdk/+/442249
Thanks!