Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Nullable: Comparers, Dictionary and Friends #23971

Merged
merged 4 commits into from
Apr 25, 2019

Conversation

safern
Copy link
Member

@safern safern commented Apr 13, 2019

Depends on latest compiler to be pulled in + all errors introduced in regression: dotnet/roslyn#34976 to be fixed.

@safern safern requested a review from a team April 13, 2019 19:23
@safern
Copy link
Member Author

safern commented Apr 15, 2019

We need to decide what to do with Dictionary because TKey should be non-nullable but the only way we have to do that is by constraining where TKey is object -- however we need to figure out if that causes boxing or some unexpected behaviour that would cause it to be a breaking change.

cc: @jkotas any input on this?

@jkotas
Copy link
Member

jkotas commented Apr 15, 2019

where TKey is object

Is this the actual syntax? What is the compiler version I need for this?

Yes, whatever we do for annotating Dictionary should better not change the IL.

@stephentoub
Copy link
Member

Is this the actual syntax?

where TKey : object

@jkotas
Copy link
Member

jkotas commented Apr 15, 2019

where TKey : object

This results into IL change. In theory, it should not break anything. In practice, there is a chance that it will break some places in unexpected ways. We have not done a change like this before so it is hard to predict.

For example, typeof(Dictionary<>).GetGenericArguments()[0].GetGenericParameterConstraints().Length is 0 today and it is going to be 1 with this change. There may be code out there that depends on it to be 0.

@safern
Copy link
Member Author

safern commented Apr 16, 2019

For example, typeof(Dictionary<>).GetGenericArguments()[0].GetGenericParameterConstraints().Length is 0 today and it is going to be 1 with this change. There may be code out there that depends on it to be 0.

So based on that, you think we shouldn't constrain TKey?

@jkotas
Copy link
Member

jkotas commented Apr 16, 2019

It may ok, but we need to be prepared to explain and defend the change once/if breaks show up.

@safern safern force-pushed the NullableCollections branch from 6a9d7f7 to 54cee1f Compare April 22, 2019 22:38
@safern
Copy link
Member Author

safern commented Apr 22, 2019

I added the constraint and rebased to fix merge conflicts. This is ready for review, PTAL.

@safern
Copy link
Member Author

safern commented Apr 25, 2019

I've addressed feedback. Had to add a bunch of ! in ValueTuple due to IEqualityComparer.GetHashCode marked as not accepting nulls.

@safern safern merged commit f54190c into dotnet:NullableFeature Apr 25, 2019
@safern safern deleted the NullableCollections branch April 25, 2019 23:12
krwq pushed a commit that referenced this pull request Apr 26, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback
krwq pushed a commit that referenced this pull request Apr 27, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Apr 30, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
krwq pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request May 1, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
krwq pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request May 1, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
safern added a commit to dotnet/corefx that referenced this pull request May 1, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request May 2, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request May 2, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request May 2, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request May 2, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
marek-safar pushed a commit to mono/mono that referenced this pull request May 2, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
jkotas pushed a commit to dotnet/corert that referenced this pull request May 3, 2019
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback

Signed-off-by: dotnet-bot <[email protected]>
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Nullable: Comparers, Dictionary and Friends

* Add object constraint to Dictionary

* Fix warning from new compiler and annotating dictionary

* PR Feedback


Commit migrated from dotnet/coreclr@ad38bf7
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants