# New Ticket Created by Moritz Lenz # Please include the string: [perl #125694] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=125694 >
Related to, but distinct from RT #125606: role A { method !foo(A:D:) { say "success!" } }; role B { method !foo { ... }; method bar {self!foo } }; class C does B does A { } C.new.bar(); # dies with "Stub code executed" If one puts method bar into class C, it works. I think it should also work with method bar in role B: both the public and the private method are copied into class C, so there is no reason why self!foo must pick the private method from the same role. FWIW this is not an optimizer bug; running with --optimize=off produces the same result. The generated code is basically C.new.dispatch:<!>('foo', B), which searches for private methods in role B, not in class C. So I guess the code could be changed to generate to calls .dispatch:<!>('foo', C), but I have no idea how to find the correct type. Maybe (in pseudo-code): if $type.^is-role { $type = self.^mro.first($type) }