Fix infinite loops.

In both cases, we were sending X? type, therefore automatically resolving
to X.Equals(object), instead of X.Equals(X).