Because of interfaces they can have multiple different common ancestors.
One could add a requirement that it only auto-converts if the ancestor is unambiguous. But then adding additional interfaces a class implements suddenly becomes a breaking change. And that might not be desirable.
For example suppose you make these types implement ISerializeable
. This shouldn't change the behavior of your code, but if you supported that casting to common interface it would.
edit: Thought a bit more about it and noticed that this function already has exactly the same problem:
T MyFunc(T left,T right)
And this code doesn't compile:
ICollection r=MyFunc(new List() , new LinkedList());
because it can't decide which type to use as the type-parameter T
. So the behavior of the ?: operator is consistent with overload resolution.