stevan / p5-mop-redux

A(nother) MOP for Perl 5
139 stars 36 forks source link

metaclass compatibility for attributes and methods #69

Closed doy closed 11 years ago

doy commented 11 years ago

This involves two separate issues. First, the classes in attribute_class and method_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.

doy commented 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.

doy commented 11 years ago

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.

doy commented 11 years ago

The circular dependency issue has been fixed by just disallowing them entirely.

doy commented 11 years ago

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.

doy commented 11 years ago

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.

doy commented 11 years ago

Okay, I think this is done now.