Hey Kamil,
What happens when you "does" a role in a class, you "mix in" all the
methods at the "same level", basically as if you had copy-pasted the
method declarations over. That's why you get the error that the call to
xyz is ambiguous.
When you "is" a class, you derive from it. That's why the multi method
X::xyz gets "overwritten" by Y::xyz, as the signature is identical.
At least that's my understanding.
Btw, you can also "is" a role, in which case it will get "punned" into a
class. That operation is equivalent to declaring a class with an empty
body that "does" the given role. So in the upper example, with role X
and class Y, you could "is X" and get the same behavior as in the lower
example.
Hope to help (and hope what I wrote is actually accurate)
- Timo