Subject: | applying a role to a non-Moo* class, with Moose loaded, after Role::Hooks has installed its patches, dies |
use Moose (); # needs to be loaded
use Role::Hooks;
{
package MyRole;
use Role::Tiny;
Role::Hooks->before_apply(__PACKAGE__, sub { });
}
{
package OtherRole;
use Role::Tiny;
}
{
package MyClass;
use Role::Tiny::With;
with 'OtherRole'; # <--- this throws
}
The exception is:
Can't call method "isa" on an undefined value at ..../Role/Hooks.pm line 51
This is because Moose::Util::find_meta() returns undef for non-Moose classes.
I initially noticed this in an application that used a library using Role::Hooks. The application applied a Moo::Role to a Mojo::Base-based class, neither of which had anything to do with Role::Hooks.
I think the smallest patch it to `use Safe::Isa` and use `->$_isa()` test in `is_role` (tested, it works)