I don't know what the expected behavior is but it seems odd/wrong:
http://dpaste.dzfl.pl/a390f1f4Note that there are two issues here(almost the same). First is that A.foo isn't called and second is that the order of inheritance on A matters(: X, Y vs : Y,X).
I would expect that A.foo(A) should match first and the ambiguity created from the inheritance should result in an error.