Fix nullable analysis involving extensions and collection expressions#78926
Merged
RikkiGibson merged 7 commits intodotnet:mainfrom Jun 17, 2025
Merged
Fix nullable analysis involving extensions and collection expressions#78926RikkiGibson merged 7 commits intodotnet:mainfrom
RikkiGibson merged 7 commits intodotnet:mainfrom
Conversation
jcouv
reviewed
Jun 16, 2025
| resultBuilder.Add(_visitResult); | ||
| } | ||
|
|
||
| void visitElement(BoundNode element) |
Member
There was a problem hiding this comment.
This local function captures, which will cause allocations
Also please avoid local function in the middle of the method logic (this could be done in a later commit to reduce diff for now)
jcouv
reviewed
Jun 16, 2025
| comp.VerifyEmitDiagnostics( | ||
| // (7,19): warning CS8604: Possible null reference argument for parameter 'o' in 'void E.Add(MyCollection c, object o)'. | ||
| // MyCollection c = [oNull, oNotNull]; | ||
| Diagnostic(ErrorCode.WRN_NullReferenceArgument, "oNull").WithArguments("o", "void E.Add(MyCollection c, object o)").WithLocation(7, 19)); |
Member
There was a problem hiding this comment.
Analysis of extension Add methods is punted as it seems much less common.
nit: That seems fine. Consider adding tests to illustrate some of the known gaps (Add extension method on Collection<object> but our target collection type is Collection<object?>, for example)
333fred
approved these changes
Jun 17, 2025
CyrusNajmabadi
added a commit
to CyrusNajmabadi/roslyn
that referenced
this pull request
Jun 18, 2025
Fix more Update versions Fix more In progress Flip Fix Fix remove wrapper Fix Fix in progress Fix DeclarationKind layering fix One building In progress Breaking out refactoring helpers into core api vs service VB side In progress Move type workaround Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems Fix SubText ctor parameter verification. (dotnet#78989) * Fix SubText ctor parameter verification. This ctor currently throws given a zero length span at the end (and only the end) of the subtext. This evidently became far more prevalent with this (fairly) recent change to optimize newline information in our sourcetext classes. (dotnet#74728) It doesn't make to allow zero length spans at all locations but at the end of the subtext, so the fix is just to allow construction in that case too. Big props to Manish Vasani for providing a very actionable repro for this. Fixes dotnet#78985. Note there is a potentially related issue outlined in dotnet#76225 that looks attributable to the PR above too. It possible that this addresses that issue too, but I'm not completely convinced. Extensions: bind unconditionally of LangVer (dotnet#78947) Extensions: use specific tracking issues for different areas (second pass) (dotnet#78971) Fix nullable analysis involving extensions and collection expressions (dotnet#78926) Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/CSharpCompilerExtensions.projitems in progrss Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems Update src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/VisualBasicCompilerExtensions.projitems extensions Fix RootNamespace Fixes Fixes IN progress in progress
ToddGrun
added a commit
to ToddGrun/roslyn
that referenced
this pull request
Jul 10, 2025
…ressions (dotnet#78926)" This reverts commit 69ec88d.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #78828 (fixes an assertion failure for a collection-expression involving extension Add)
Related to #68786.
I decided to go ahead and implement analysis of the mainline case of
List<string> list = [null];for example as there have been multiple bug reports about the diagnostic being missing. Analysis of extension Add methods is punted as it seems much less common.