Failing to do so lead the codegen to emit invalid code sometimes, especially when C++ references were involved. Fixes #10241