PR7952: Make isa<> use the same logic as cast<>, so that they both work