We didn't correctly process the case where a base class is classified as MEMORY. This would cause us to trip over an assertion.
This fixes PR24020.
lgtm