-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add default methods to allow evolutions on classes #30416
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
+1. We strongly need either this and/or something like C#'s extension methods. Otherwise it is too painful to evolve any library, which leads to a lot of fragmentation. |
In the language team we have discussed adding support for default methods for a while, using exactly the same motivation as given here (to allow widely used interfaces to grow). I've added a reference to this issue in an internal language design issue, to ensure that we're aware of this input on the matter. |
The lack of something like this just made a ~5 minute task into a ~5 hour one :( |
Yep, deferring this to the language repo issue. |
I really like Dart implicit interface (every classes can be used as interface) but it makes harder to make evolutions on classes.
For instance it's almost impossible today to add a method to
Map
orList
without releasing a major version.In Java, interfaces can evolve with the addition of default methods. Those methods are implemented only based on the interface methods.
I wondered if something like that could be done in Dart.
For instance, we could add a method
groupBy
onMap
:and my class
MyMap
that implementsMap
would have the new method without breakage. It would break only if the implementation as a method with the same name but with different parameters.WDYT?
The text was updated successfully, but these errors were encountered: