This is a real situation, but I will use fake numbers. Let's say I invest $10,000 in an investment trust and my shares eventually appreciate to the point where they are worth $60,000. This is not an equity position, but a debt position because my shares represent assets that are supposed to be held by the trust. Then something bad happens and the company goes bankrupt. The bankruptcy trustees assess the value of my shares at $60,000 (the amount the company owes me) and then announce that they are liquidating the company and paying out 1/3 of par value to the creditors, therefore I will receive $20,000. In this case I will ultimately get returned to me more than I originally "loaned" to the company, but I will lose a lot of what they owed me. Legally speaking I am a "creditor" of the company, not a "shareholder".
In this case, from a tax perspective (United States), have I suffered a gain or a loss?
(As an analogy, suppose a bank loans $500,000 to a business and according to the terms of the loan, the business ends up owing $600,000 including interest. But then suppose the business goes bankrupt and after the liquidation the bank is only paid $540,000. Has the bank had a $40,000 gain or a $60,000 loss? This is analogous to my situation.)