Are you sure it works with plain Moose? Because I've tried this and it fails with a very similar error message:
use v5.14;
use strict;
use warnings;
package RoleA {
use Moose::Role;
requires 'm1';
sub m2 {
my $self = shift;
$self->m1." World!\n";
}
}
package RoleB {
use Moose::Role;
has 'm1' => ( accessor => 'm1', is => 'ro', isa => 'Str', default => 'Hello');
}
package ClassA {
use Moose;
with qw/ RoleB RoleA /;
sub m3 {
my $self = shift;
$self->m2();
}
}
print ClassA->new()->m3();
There are a number of issues in Moose (and corresponding TODO test cases in the test suite) revolving around attributes in roles not satisfying requires
in other roles. For example, bug RT#77406 is similar (though not identical).
UPDATE by manually composing the roles one-at-a-time, in a particular order, you can make it work:
use Moops;
role RoleA using Moose {
requires 'm1';
method m2() {
$self->m1." World!\n";
}
}
role RoleB using Moose {
has 'm1' => ( is => 'ro', isa => 'Str', default => 'Hello' );
}
class ClassA using Moose {
with 'RoleB';
with 'RoleA';
method m3() {
$self->m2();
}
}
print ClassA->new()->m3();