Fix self-inheritance detection.