Backport "Fix Baseclass becomes! subclass." for 4.1

Backports #14971 for 4-1-stable.