Skip to content

Conversation

@RenderMichael
Copy link
Contributor

Fixes #77084

The fix for the old issue #58636 was more conservative than it needed to be. This allows eg. bool to be returned to an object target in a switch expression arm without a cast.

@RenderMichael RenderMichael requested a review from a team as a code owner February 10, 2025 20:28
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 10, 2025
@dotnet-policy-service dotnet-policy-service bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode labels Feb 10, 2025
@RenderMichael RenderMichael reopened this Apr 13, 2025
@CyrusNajmabadi
Copy link
Member

Thanks for the initial PR. I moved the fix to the right location.

Func<TConditionalOrSwitchExpression, ExpressionSyntax, ExpressionSyntax?> getAlternativeArm,
CancellationToken cancellationToken)
where TConditionalOrSwitchExpression : ExpressionSyntax
{
Copy link
Member

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.

@CyrusNajmabadi CyrusNajmabadi merged commit 25a24cb into dotnet:main Aug 8, 2025
24 of 25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 8, 2025
@CyrusNajmabadi
Copy link
Member

Thannks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. untriaged Issues and PRs which have not yet been triaged by a lead VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary cast added to the default arm in the IDE0066 fixer

3 participants