forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better exclude local functions from region analysis
By design, when data flow analyzes local functions it does so devoid of surrounding context and records possibly unassigned variables rather than reporting a diagnostic. Thus, all captured variables are expected to be marked unassigned during data flow analysis without reporting a diagnostic. However, reporting a diagnostic is not the only side effect of running data flow analysis. By calling virtual methods data flow analysis informs derived types of unassigned variables. While the diagnostic is supressed and recorded, currently the virtual method is still called. This has negative consequences for region analysis, which considers these calls as indications of variables flowing out of the given region, which may not be the case for local functions. This PR changes data flow analysis to only call the ReportUnassigned virtual method if not inside a local function, excluding local functions from all unassignment reporting. Fixes dotnet#17165, dotnet#18347
- Loading branch information
Showing
9 changed files
with
556 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.