Skip to content

Unions: Remove some trivial wrapper methods - #84678

Merged
AlekseyTs merged 1 commit into
dotnet:mainfrom
AlekseyTs:Unions_85
Jul 29, 2026
Merged

Unions: Remove some trivial wrapper methods#84678
AlekseyTs merged 1 commit into
dotnet:mainfrom
AlekseyTs:Unions_85

Conversation

@AlekseyTs

@AlekseyTs AlekseyTs commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
Microsoft Reviewers: Open in CodeFlow

@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 with NamedTypeSymbol.UnionValuePropertyNoUseSiteDiagnostics().
  • Replace other removed Binder wrappers (HasTryGetValueSignature, IsUnionTypeTryGetValueMethod, GetUnionTypeHasValueProperty, GetUnionTypeTryGetValueMethod) with direct NamedTypeSymbol calls.
  • Delete the now-unused wrapper methods from Binder_Patterns.cs and add the new internal helper on NamedTypeSymbol.

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.

@AlekseyTs
AlekseyTs enabled auto-merge (squash) July 29, 2026 15:06
@AlekseyTs
AlekseyTs merged commit d15aa7f into dotnet:main Jul 29, 2026
25 of 26 checks passed
@jjonescz jjonescz added this to the 18.11 milestone Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants