Permanent Polymorph Any Object and levelling up

Suppose a character is under the effect of a Polymorph Any Object spell with a duration of Permanent. When they gain their next level, they gain an ability score increase and apply it to one of the stats that is permanently changed (Str, Dex, Con, or Int). Then, later, the effect is dispelled. What happens to the stat boost? Is that lost, as well? Does it carry back to the original character’s stats? This carry-over seems to be one way if it does, as you do not augment your polymorphed form with previously attained ability score increases. But it also seems pretty harsh to have the character lose the ability score increase after they succeed on removing the Polymorph Any Object spell.

Similarly, what happens if a wizard turns themself into an ethergaunt permanently. This provides a rather small, but not insubstantial, intelligence boost. If they gain levels while they are an ethergaunt, would they gain more skill points than normal for having a higher intelligence score?