Closed doy closed 11 years ago
The implementation in 1ad8903 isn't quite complete - it will break in the case of cycles in load order. For instance, if package A loads class B which extends class A, then a method in B that overrides a method in A won't see the method override at the point where add_method
is called, and so metaclass compat won't be fixed up properly.
There's another issue here too - if a role contains a method which uses a custom metaclass and a class consumes that role and also overrides that method, it also needs to check compatibility.
The circular dependency issue has been fixed by just disallowing them entirely.
We also need to fully decide on the model for attributes before this can be finalized (see #73). If attributes are all merged into a single namespace (like methods are), then this sort of compat fixing is correct. If they aren't (which is the current state), then it is not.
The issue with role composition has been partially fixed, but can't be completely fixed until we deal with #67, since we throw away important information when we just turn method conflicts into required methods.
Okay, I think this is done now.
This involves two separate issues. First, the classes in
attribute_class
andmethod_class
need to be compatible with the superclass versions, so that a class metaclass can define those and be able to assume that every attribute or method will conform to that API, even in subclasses. Second, overriding an attribute or method should make the metaclass of that specific attribute or method compatible with the metaclass of the attribute or method that it is overriding.