Implement `sameImpl` generically.