Skip to content

Misc. Union changes#82448

Open
AlekseyTs wants to merge 1 commit intodotnet:features/Unionsfrom
AlekseyTs:Unions_18
Open

Misc. Union changes#82448
AlekseyTs wants to merge 1 commit intodotnet:features/Unionsfrom
AlekseyTs:Unions_18

Conversation

@AlekseyTs
Copy link
Contributor

  • Null pattern for classes
  • TryGetValue nullable analysis

- Null pattern for classes
- TryGetValue nullable analysis
applyMemberPostConditions(receiverSlot, type, notNullWhenFalseMembers, ref StateWhenFalse);
}

if (method is MethodSymbol
Copy link
Member

Choose a reason for hiding this comment

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

It might be reasonable to share the isTryGetValueSignature helper from GetUnionTypeTryGetValueMethod here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be reasonable to share the isTryGetValueSignature helper from GetUnionTypeTryGetValueMethod here.

If I remember correctly the logic doesn't match exactly.

CompileAndVerify(comp1, expectedOutput: "1323 -1-3-2-3").VerifyDiagnostics(
// (26,50): hidden CS9335: The pattern is redundant.
// return u switch { int => 1, string => 2, null => 3 };
Diagnostic(ErrorCode.HDN_RedundantPattern, "null").WithLocation(26, 50),
Copy link
Member

@RikkiGibson RikkiGibson Feb 18, 2026

Choose a reason for hiding this comment

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

This warning still seems misleading, per the prototype comment from before this change. Should the prototype comment be restored? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This warning still seems misleading, per the prototype comment from before this change. Should the prototype comment be restored?

No the hidden diagnostic is expected now, null can be replaced with an _ and the meaning won't change

Copy link
Member

Choose a reason for hiding this comment

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

I keep missing the HDN_ prefix on these.

@RikkiGibson
Copy link
Member

Test failure looks like an infra issue.

@AlekseyTs AlekseyTs requested a review from a team February 19, 2026 00:19
@AlekseyTs
Copy link
Contributor Author

@333fred, @dotnet/roslyn-compiler For a second review

1 similar comment
@AlekseyTs
Copy link
Contributor Author

@333fred, @dotnet/roslyn-compiler For a second review

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.

2 participants

Comments