Good to know, thanks. I don���t know the philosophy behind this case, but from my point of view - trait requires a method, and the class has it, it���s just that the method is defined higher in the hierarchy.
I agree, this is the behavior I would expect too. From this point of view, the problem is the 20% slowdown.
A solution would be that traits does not install explicit requirements in their users if suitable methods are already in their hierarchy.
Then traits needs to listen to method addition/removal announcements to install/remove the explicit requirement methods in their users accordingly.
Another solution is to never install explicit requirement methods and have a modified version of doesNotUnderstand: that detect when the missing method is an explicit requirement.
So we have four solution:
- explicit requirements does not override methods in the hierarchies of the trait users:
1. current situation: nothing to do but 20% slowdown (but no slowdown by removing the explicit requirement from the trait composition).
2. automatic installation/removal of explicit requirement in traits users: adds more complexity in trait installation logic but transparent to user.
3. dynamic detection of explicit requirement in doesNotUnderstand: slower DNU but still transparent to user.
- explicit requirements always override methods in the hierarchies of the trait users:
4. explicit resolution by removing overriding explicit requirements from trait compositions: less magic but maybe confusing for users
I vote for 2 (then 1, 3, 4).
Camille