Refine type checking for equality comparisons.