Incorrectly detects framework on roles when Moo is loaded
bbrtj opened this issue · comments
This example fails:
require Moo::Role;
package ThisFailsRole {
use Mouse::Role;
use Sub::HandlesVia;
}
use Test::More;
no feature 'indirect';
is Sub::HandlesVia->_detect_framework('ThisFailsRole'), 'Mouse', 'role ok';
done_testing;
The reason for this is that Moo::Role handles Moose / Mouse itself: https://metacpan.org/dist/Moo/source/lib/Moo/Role.pm#L163. So if only it is loaded, it will always think it handles Moo.
Additionally:
use Sub::Util qw(subname);
use Data::Dumper;
die Dumper(subname(\&ThisFailsRole::has));
# Sub::HandlesVia::Toolkit::Moo::has
So it actually installed has
wrapper from Moo, as suspected from _detect_framework
result above.
Given the number of CPAN modules that may load Moo, this could be problematic.
Note: same problem with Moose::Role.
Changing the order which the checks happen would probably fix this.
Changing the order breaks Moo classes when Moose is loaded.
Tightening up the Moo::Role check seems to work better.