I would argue that this is such a basic C++ rule that no, this doesn’t require an assertion. Maybe a documentation update that says “this might return nullptr if it’s a TopLevelWindow” or something like that…
Maybe you misunderstood the problem. The problem isn’t about getParentComponent returning a null pointer and the documentation already mentions that can do it. The problem is that Component::addChildComponent happily “works” when used on an object instance dereferenced from a null pointer.
I’m fairly certain in C++ that this can never be nullptr. Read another way, it’s not legal to call methods through a nullptr variable so the compiler is free to optimise anything that checks this != nullptr and assume it’s always true.
Basically, it’s best avoided and you have to do the checks yourself before making the addChildComponent call.