I have a class that does a role that does another role. A method from the class can access an attribute in the top level role:
role A {
has $.x
}
role B does A {
}
class C does B {
method this() { say $!x }
}
C.new(:x(1)).this;
That works fine and says 1 like I think it should.
But I have a number of classes that all do role B, that I want to share the method this(), so I move it up into role B:
role A {
has $.x
}
role B does A {
method this() { $!x }
}
class C does B {}
C.new(:x(1)).this;
That won't even compile: SORRY Attribute $!x not declared in role B.
Can a role not see attributes in a role it includes?