Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature nullness :: Subsume nullness for contravariant type parameters (such as the one in IEqualityComparer<in T>) #17398

Merged
merged 3 commits into from
Jul 11, 2024

Conversation

T-Gro
Copy link
Member

@T-Gro T-Gro commented Jul 9, 2024

This feature is driven by an occurence of BCL type design which I encountered during testing.

IEqualityComparer<in T>
StringComparer.Ordinal : IEqualityComparer<string | null>
But constructors of all dictionary-like types needing an IEqualityComparer<string>

Which would not much.
At the same time, natural conversion from Type<T | null> to Type cannot be done out of the box, since we cannot control how the T is used internally.
This nullness-equality relaxation can only be done for contravariant generic parameters (<in T>), which is used for interfaces taking the generic typar in its input.

@T-Gro T-Gro requested a review from vzarytovskii July 10, 2024 08:26
@T-Gro T-Gro marked this pull request as ready for review July 11, 2024 07:29
@T-Gro T-Gro requested a review from a team as a code owner July 11, 2024 07:29
@T-Gro T-Gro merged commit 57026b8 into feature/nullness Jul 11, 2024
28 checks passed
@T-Gro T-Gro deleted the feature-nullness-variance branch July 11, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant