Suicide isn't the opposite of optimism though. Suicide is an action, optimism is an attitude. Pessimism would be the opposite of optimism. But sure- both could be viewed as delusions or, accurate I suppose.
A person who has achieved grade A's throughout life, had multiple good job opportunities come up, had plenty of people find them attractive may very well feel optimistic about their future. Why wouldn't they?
Who's to say an optimistic attitude isn't inherited and further reinforced by upbringing? Similarly for a pessimistic outlook. I dread to think how my would-be children would turn out! Hence, I don't have any.
Even then though- is it an actual delussion? Do optimists truly believe that no harm will ever befall them? I doubt it. They're not stupid. They must know about death, illness, job redundancy etc. They likely just find their life easier to cope with if they focus on their strengths and the better things.
But, suicide is the opposite of living. So, the question is surely more- who's the more delluded? Those who choose to live or die?
Again, that depends on their circumstances and their experience of life. If it's good- why would they suicide? If it's bad though then, it's up to them. They could try to cling to hope and optimism. Maybe it would work- maybe their life would improve. In which case, it wasn't a delusion, it was a hope that came true.
If they decide to suicide though, then it depends on your belief. Either they relieved themselves from life. Even if it had the potential to get better, maybe it doesn't matter. They're not alive to regret the action. If you wonder about the possibility of an afterlife though- it could have worse consequences.
The problem with both optimistic and pessimistic views on the future is they're just that- views about the future. The future is unknown. They're both delussional in that sense but likely based on previous experience.
The problem with pessimism though is, it could be a result of depression. If depression is an illness then, it means the brain is negatively and abnormally skewed. So- can we trust that it's perceiving things correctly?
I'm not sure the same can be attributed to optimists. Perhaps people going through psychosis with delusions of grandeur but- that isn't the majority I imagine. I'd imagine that a great many suicidal people do have depression.
Regardless though- whether it's a delluded or accurate way of seeing the world, it's still a problem if it can't be adequately adjusted.
The bigger problem with suicide though is, it's a very disruptive action. Unlike a pessimist or optimist who can just be ignored if we find them irritating, suicides cause other people to grieve deeply. So, they aren't exactly a passive choice.