Unions: Remove some trivial wrapper methods - #84678
Merged
Merged
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors union-related helper usage in the C# compiler by removing trivial Binder wrapper methods and calling the underlying NamedTypeSymbol union APIs directly (plus introducing a small NamedTypeSymbol convenience helper for the “discard use-site diagnostics” pattern).
Changes:
- Replace
Binder.GetUnionTypeValuePropertyNoUseSiteDiagnostics(...)call sites withNamedTypeSymbol.UnionValuePropertyNoUseSiteDiagnostics(). - Replace other removed
Binderwrappers (HasTryGetValueSignature,IsUnionTypeTryGetValueMethod,GetUnionTypeHasValueProperty,GetUnionTypeTryGetValueMethod) with directNamedTypeSymbolcalls. - Delete the now-unused wrapper methods from
Binder_Patterns.csand add the new internal helper onNamedTypeSymbol.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs | Switch union value-property lookup to the new NamedTypeSymbol helper. |
| src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs | Add UnionValuePropertyNoUseSiteDiagnostics() convenience method to centralize the “discard use-site info” pattern. |
| src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs | Update union nullability/flow analysis paths to use NamedTypeSymbol helpers directly. |
| src/Compilers/CSharp/Portable/Binder/UnionMatchingRewriter.cs | Use NamedTypeSymbol.UnionValuePropertyNoUseSiteDiagnostics() instead of the removed Binder wrapper. |
| src/Compilers/CSharp/Portable/Binder/DecisionDagBuilder.cs | Replace removed Binder wrappers with direct NamedTypeSymbol calls for union pattern DAG building. |
| src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs | Remove trivial wrapper methods and update remaining helpers to call NamedTypeSymbol APIs directly. |
jjonescz
approved these changes
Jul 29, 2026
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.
Microsoft Reviewers: Open in CodeFlow