-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Apply dart fixes to abstract classes, and subsequent implementing classes #46464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you explain what you mean by a "fix"? Do you mean a quick fix, in the IDE, or a |
I believe that this is referring to a data-driven fix. |
Yes, @bwilkerson is correct! :) |
The issue is that these are changes to constructors, and constructors don't override constructors. If it had been a change to an instance method in the abstract class then I believe it would have automatically applied to all overrides of the method. I haven't thought deeply about it, but my first take is that we could support an 'apply to subclasses' flag for changes to constructors that would cause constructors in subclasses to be included similar to the way we include overrides. We'd probably want to restrict this to classes that directly or indirectly extend the class (as opposed to those that implement the class). |
I ran into a case where this would be helpful as well. Specifically while making fixes for flutter #122323. The base class As another point in favor for allowing fixes to apply to a class and its implementations is in the case of a class that's expected to be implemented outside of the library with the base class. In this case, the If the fix created for |
@pdblasi-google , what type of parameter is With regards to being able to making use of the data file across packages, as mentioned above, we are not looking to add support for this use case. For now creating a data file in the package, copy paste transforms and running dart fix again is the way to go. |
@keertip I had intended on copying and pasting as you suggested and as we have to do internal to a single package as well for this specific case. The intent on providing the example was to reinforce Piinks` use case. If a fix written for a base class could apply to it's implementations, then when This same benefit would apply to the classes |
There are some subtleties here that make this complicated. It's certainly the case that if we know about a change to the parameters of a method Given the It's details like that that we're concerned about and that make us think that we might not want to allow transforms for superclasses to be used on subclasses. |
I think that makes total sense. Alternatively, I think it would go a long way if Something like 'hey there, you are overriding a deprecated method.' could make a huge difference. |
That idea came up recently in another context as well. I think that makes sense most of the time, but there are a few times when it doesn't and I don't know how to avoid the false positives. |
I have noticed in writing a few flutter fixes that you cannot write a fix for an abstract class. Instead, you must write the fix for every implementing class. Not sure of it is possible, but it might be nice to just write a fix for the abstract class and have it apply to all the sub classes.
One example is https://github.com/flutter/flutter/pull/81858/files
Writing a fix for GestureDetector.kind meant writing fixes for 17 subclasses.
The text was updated successfully, but these errors were encountered: