The restriction applies regardless of the order
The rule on bonus-action spells states:
You must use a bonus action on your turn to cast the spell, provided that you haven't already taken a bonus action this turn. You can’t cast another spell during the same turn, except for a cantrip with a casting time of 1 action.
No matter when the bonus action spell is cast, you cannot have cast another spell except for a cantrip with a casting time of one action for the entire turn. This turn-based stipulation does indeed mean the restriction applies retroactively. It doesn't matter what order - as long as the two spells are cast (or attempted to be cast) on the same turn, the restriction applies.
Jeremy Crawford has also clarified and agrees with this:
Q: How do bonus action spell rules go when a noncantrip is cast as a single action then a bonus action spell?
JC: If you cast a spell of 1st-level or higher with 1 action, you can't then cast a bonus action spell.
Note that things can get confusing when applying this rule and this question has a nice table showing all the legal and illegal combinations.