Predicate Unification::unifiable
Holds if types t1 and t2 are unifiable. That is, it is possible to replace
all type parameters in t1 and t2 with some (other) types to make the two
substituted terms equal.
This predicate covers only the case when t1 and t2 are constructed types;
the other three cases are:
- Neither
t1nort2are type parameters; in this caset1andt2must be equal. t1ort2is an unconstrained type parameter; in this caset1andt2are always unifiable.t1ort2is a constrained type parameter; in this case the predicateConstrainedTypeParameter::unifiable()can be used.
For performance reasons, type parameter constraints inside t1 and t2 are
not taken into account, and there is also no guarantee that the same type
parameter can be substituted with two different terms. For example, in
class C<T1, T2>
{
void M<T3>(C<T3, T3> c) where T3 : struct { }
}
the type C<T3, T3> is considered unifiable with both C<object, object> and
C<int, bool>.
Note: This predicate is inlined.
Import path
import semmle.code.csharp.Unification