File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -685,6 +685,33 @@ This allows you to create roles that act as abstract interfaces.
685
685
The implementation of the stubbed method may also be provided by another
686
686
role.
687
687
688
+ = head2 Inheritance
689
+
690
+ Roles cannot inherit from classes, but they may cause any class which does
691
+ that role to inherit from another class. So if you write:
692
+
693
+ = begin code
694
+ role A is Exception { }
695
+ class X::Ouch does A { }
696
+ X::Ouch.^parents.say # ((Exception))
697
+ = end code
698
+
699
+ ...then C < X::Ouch > will inherit directly from Exception, as we can see above
700
+ by listing its parents.
701
+
702
+ = head2 Pecking order
703
+
704
+ A method defined directly in a class will always override definitions from
705
+ applied roles or from inherited classes. If no such definition exists, methods
706
+ from roles override methods inherited from classes. This happens both when
707
+ said class was brought in by a role, and also when said class was inherited
708
+ directly.
709
+
710
+ Note that each candidate for a multi-method is its own method... in this case,
711
+ the above only applies if two such candidates have the same signature.
712
+ Otherwise, there is no conflict, and the candidate is just added to the
713
+ multi-method.
714
+
688
715
= head2 Automatic Role Punning
689
716
690
717
Any attempt to instantiate (and many other kinds of usage) a role will
You can’t perform that action at this time.
0 commit comments