KEMBAR78
Fix issue where we were not offering 'use collection expression' in a nullable scenario. by CyrusNajmabadi · Pull Request #71528 · dotnet/roslyn · GitHub
Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

Fixes #71522

@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 7, 2024
@CyrusNajmabadi CyrusNajmabadi force-pushed the useCollectionConditional branch from ffa0f37 to 2e3f925 Compare January 7, 2024 19:40
return CompareAcrossSemanticModels(symbol, newSymbol);
}

if (symbol.Equals(newSymbol, SymbolEqualityComparer.IncludeNullability))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RikkiGibson @cston this is the IDE change i had to make to workaround the issue.


[Theory, CombinatorialData, WorkItem("https://github.com/dotnet/roslyn/issues/71522")]
public async Task TestTargetTypedConditional1(
[CombinatorialValues("", "#nullable enable")] string nullable)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests demonstrate the problem.

@CyrusNajmabadi CyrusNajmabadi changed the title WIP: Conditional expr fix Fix issue where we were not offering 'use collection expression' in a nullable scenario. Jan 8, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review January 8, 2024 17:32
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 8, 2024 17:32
@CyrusNajmabadi
Copy link
Member Author

@akhera99 ptal

@CyrusNajmabadi
Copy link
Member Author

@RikkiGibson do you want me to hold off on this? I can also merge in, and you can adjust things back if you end up changing the compiler side.

@RikkiGibson
Copy link
Member

I have no strong opinion here about whether to merge the PR. It will maybe help buy the compiler side time to fix up the public API behavior.

I don't have a strong understanding of the code that was changed in this PR. But I thought I would point out that the compiler sometimes internally uses TypeCompareKind.ObliviousNullableModifierMatchesAny. There are times where it's acceptable for either an annotated or non-annotated type to unify with an oblivious type. It's possible that such a behavior is also desirable here, I'm not sure.

@CyrusNajmabadi
Copy link
Member Author

@RikkiGibson ok. i'll merge in. you'd be able to repro the issue by keeping the tests added in this pr, but undoing the other code changes. You'll see a call to arraysymbol's .Equals override.

@CyrusNajmabadi CyrusNajmabadi merged commit 2a97538 into dotnet:main Jan 8, 2024
@ghost ghost added this to the Next milestone Jan 8, 2024
@Cosifne Cosifne modified the milestones: Next, 17.10 P1 Jan 30, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the useCollectionConditional branch March 21, 2024 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDE0300 fix-all skips first diagnostic in a cascading ternary

4 participants