Corporate finance used to be simple. In a bankruptcy, bondholders would get their money first, then subordinated bondholders, and eventually shareholders. But the 2008 crisis happened, and a lot of old-style corporate finance was thrown out of the window.
The 2010 G20 summit in Washington created a new world order for bank failures, based on a few key principles:
Avoid the use of taxpayer money
Implement far-reaching crisis resolution tools to avoid contagion
In any case, treat all investors fairly and maintain the “no creditor worse off” principle, ie, no one should be worse off in a crisis resolution than in a bankruptcy
This was all very nice, but quickly clashed with realpolitik. The no-creditor-worse-off principle, designed to protect investors, turned into a license to kill. An estimate that bankruptcy would give zero recovery was enough for regulators to be allowed to do anything. The goal-seek approach to resolution is how we ended up with the Portuguese authorities bailing in senior bonds based on their ISIN codes starting in XS instead of PT.