Correctly handle enum merging during unit loading.
Summary:
The logic in Class::def that was trying to prevent fatals during the !failIsFatal phase incorrectly encoded the rules for valid enum base type constraints (differing from the logic in Class::setEnumType), so enums would never get loaded in this phase unless their base type resolved to exactly int or string. This meant that out-of-order enum declarations in the same unit would fail to load if their base type was not exactly int or string.
Factor this code out into a helper in TypeConstraint, and make both Class::setEnumType and Class::def use the helper. This should prevent this type of bug in the future. Add a unit test.
Reviewed By: ricklavoie
Differential Revision:
D38329638
fbshipit-source-id:
501e13487f9adecd40f68466e53e020ad5fec2b9