Because it would be too difficult to determine when such a design is really allowed.
(When the call will be unambiguous)
Although it would be possible to create a good set of rules, they would be quite complex and difficult to understand. People will eventually ask why case X does not work if it has subtle ambiguity.
For instance:
- None of the types can be an interface or a general parameter
- If one type is an enumeration or a numeric type, the other must be a class other than
object or Enum - If one type is a delegate, the other should not also be a delegation type (both
object , Delegate , and MulticastDelegate ) - One type cannot inherit another
- All of these rules apply to all types that are implicitly convertible to parameter types.
- Both types must be
sealed or must be value types
(some of these rules can be enforced instead of callsite)
In practice, such a function would have so many limitations to be almost useless.
Consequently, this feature started at -10,000 points .
It would also create a new category of violations. Unlocking a type, adding implicit conversions, or other seemingly trivial things can now break client code.
source share