[1.7.x] Fixed #23892 -- Made deconstructible classes forwards compatible

Backport of f36151ed169813f2873e13ca9de616cfa4095321 from master.