Backport fixes for sharing wrappers when type attributes are involved (#21537)