-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
It would be nice if you could add a new argument to a method in a superclass without breaking all subclasses that override that method.
We currently have this problem in Flutter (see flutter/flutter#28206) where we have an abstract class that defines a method hitTest:
abstract class CustomPainter {
bool hitTest(Offset position) => null;
}Long after this has been implemented we realized that it would be beneficial for some use cases if hitTest takes another argument of type Size:
bool hitTest(Offset position, Size size) => null;Unfortunately, this is a breaking change and would require all of our users to update their subclasses of CustomPainter.
It would be great if this could be a non-breaking change, e.i. when hitTest(position, size) is called on a subclass that only implements hitText(position) that method is executed dropping the size argument on the floor.
Potentially, the newly introduced argument in the superclass could be marked in a way to indicate that in some subclasses this method may not take that argument.