If—
(a) there is in a will a direct or indirect reference to the sex of a person or class of persons; and
(b) during the period between the making of the will and the death of the testator that person, or a person who, but for this section, would have been within that class altered their sex;
then, unless the contrary intention appears from the will or from evidence admitted under section 12B, the will has effect as if the relevant person had not altered their sex.