Skip to content

Unions: Support inheritance for TryGetValue methods#82884

Merged
AlekseyTs merged 1 commit intodotnet:features/Unionsfrom
AlekseyTs:Unions_36
Mar 29, 2026
Merged

Unions: Support inheritance for TryGetValue methods#82884
AlekseyTs merged 1 commit intodotnet:features/Unionsfrom
AlekseyTs:Unions_36

Conversation

@AlekseyTs
Copy link
Copy Markdown
Contributor

@AlekseyTs AlekseyTs commented Mar 21, 2026

Microsoft Reviewers: Open in CodeFlow

if (!inputUnionType.IsDefinition)
{
if (!inputUnionType.IsDefinition)
while (declaringType.OriginalDefinition != (object)possiblyConstructedOrSubstitutedType.OriginalDefinition)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did we go from iterating baseType1/baseType2 inheritance chains to iterating just one and fixing up the other via the inner while loop? Does it make observable difference?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are just doing slightly less work if we are dealing with a non-generic type, or dealing with generic definition. The baseType2 wasn't used then. With this change we don't even calculate it. This also aligns code with the other added helpers around TryGetValue

@AlekseyTs AlekseyTs requested a review from a team March 23, 2026 17:18
@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@RikkiGibson, @dotnet/roslyn-compiler For a second review.

3 similar comments
@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@RikkiGibson, @dotnet/roslyn-compiler For a second review.

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@RikkiGibson, @dotnet/roslyn-compiler For a second review.

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@RikkiGibson, @dotnet/roslyn-compiler For a second review.

@AlekseyTs AlekseyTs merged commit 04a2328 into dotnet:features/Unions Mar 29, 2026
24 checks passed
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