You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the result of GetIsOperatorConstantResult is no longer merely a heuristic for the quality of warnings - it is used to determine when a pattern-matching operation is illegal (when it returns false) - it is worth improving it sooner rather than later, as it would be a hard breaking change when it is tightened.
One way to do this is hinted at in the code - use TypeUnification.CanUnify to see if the input type and the tested type can possibly be substituted to types that have an inheritance relationship.
We should get LDM guidance to see if it is worth it.
The text was updated successfully, but these errors were encountered:
Cases this could help with are hinted at in the code:
// We could then go on to get more complicated. For example, //// bool M6<X>(C<X> x) where X : struct { return x is C<string>; }//// We know that C<X> is never convertible to C<string> no matter what// X is. Or://// bool M7<T>(Dictionary<int, int> x) { return x is List<T>; }//// We know that no matter what T is, the conversion will never succeed.
These cases could be handled by using unification as a subroutine. We would have to be careful regarding variance.
structS<T>{voidM(S<T>x){if(xisint){}// MISSING warning: the given expression is never of the provided ('int') type.if(xisinti){}// MISSING error: the given expression is never of the provided ('int') type.if(xis3){}// MISSING error: the given expression is never of the provided ('int') type.}}
Since the result of
GetIsOperatorConstantResult
is no longer merely a heuristic for the quality of warnings - it is used to determine when a pattern-matching operation is illegal (when it returnsfalse
) - it is worth improving it sooner rather than later, as it would be a hard breaking change when it is tightened.One way to do this is hinted at in the code - use
TypeUnification.CanUnify
to see if the input type and the tested type can possibly be substituted to types that have an inheritance relationship.We should get LDM guidance to see if it is worth it.
The text was updated successfully, but these errors were encountered: