Extend `override` check to also check arity
Now we have override to check if a subclass is overriding anything, however it doesn't care about arity for now.
@jameslopez mentioned that this reminds him rint he made before, which could also check arity.
With Module#method_added
we should be able to check arity after the overriding method is defined.
It could work like this:
- Whenever
override
checks, we know what's thesuper
(overridden) method is, and then we save the arity for that (withmethod(name).arity
) - In
method_added
, we search for the method we just checked before, and compare the arity with this newly added method's arity. - They should be equal, otherwise raise an error.
In Scala, not just arity, it would also check return type (covariant return type also supported) and arguments' types. We can't do that for Ruby but at least we could check arity.
This is important to not violate Liskov substitution principle