-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Loosen casting requirements on switch expression conversion #77139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loosen casting requirements on switch expression conversion #77139
Conversation
|
Thanks for the initial PR. I moved the fix to the right location. |
| Func<TConditionalOrSwitchExpression, ExpressionSyntax, ExpressionSyntax?> getAlternativeArm, | ||
| CancellationToken cancellationToken) | ||
| where TConditionalOrSwitchExpression : ExpressionSyntax | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the logic in here is what we had in IsConditionalCastSafeToRemove, but made generic so it can operate on a a?b:c expr vs a a switch { ... } expr, with helper functions to deal with conditional exprs only having two arms, which switches can have many.
|
Thannks! |
Fixes #77084
The fix for the old issue #58636 was more conservative than it needed to be. This allows eg.
boolto be returned to anobjecttarget in a switch expression arm without a cast.