Countries that are at the source of brain drains would typically like to do that but can't, just like they have problems solving other problems. $arbitrary country does not have the major tech companies to support tech-company level salaries and there is a chicken-and-egg problem there.
So an artificial restriction like that would indeed tilt things in their favor, which may help them solve this very problem in the long term.
If this anti-immigration trend is held over a sufficiently long time I think rich countries will start realizing what a magnificent deal they had.