Properly handle extending a class with the same name in Sniff

Fixes #1082