A caster casts polymorph on another creature. Let’s say the polymorphed creature has 10 HP in its new form, but takes 30 piercing damage and its current form is reduced to 0 HP. This causes it to revert back to its original form, with 20 more piercing damage that would carry over. However, its original form is resistant to piercing damage.
How much damage would the new form actually take? Would its original form’s resistance to the damage type apply to the carryover damage?
The same question can be extended to the original form having immunity or vulnerability, as the answer would ostensibly use the same logic.
The druid’s Wild Shape ability also works similarly to polymorph in this regard (if you reduce the new form to 0 HP, then any remaining damage carries over to its original form), so I suspect the answer would be similar for a similar question about Wild Shape.