-
Notifications
You must be signed in to change notification settings - Fork 802
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
Prefer nullable over other conversions #14319
Merged
vzarytovskii
merged 2 commits into
dotnet:main
from
NinoFloris:fix/resolution-regression-14302
Nov 17, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the ordering of these preference checks, and their global action across the overload, I'm concerned that they're too strong - preferring "methods that need less type-directed conversion" and "methods that only have nullable type-directed conversions" over all else in all situations, regardless of what else is happening (assuming there is some TDC in play in both overloads at all). This would affect method overloads where there's some TDC, and some other things in play too.
For the original addition of the "no TDC" check that's reasonable, as we didn't want that feature to affect any existing overloading. But I'm wondering whether these two further checks should go at the end of the preference list, or should be done argument by argument in
compareArg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be option 4 in #14302, because I agree, this is absolutely a kludge. It isn't really low risk to push such a refactor into a patch though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NinoFloris : I would be for merging this PR as is now, and doing a bigger change later (after next VS update/release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only downside is that code created at preview version might behave differently now.
But in general I agree with considering this a bugfix and not preferring nullable overloads was a bug ( = decreases strictness of backwards compatibility view)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To balance the situation a bit @dsyme, we are not making more overload sets ambiguous than we were doing in F# 6 (correct me if I'm wrong). Overload sets where per argument checks will start to resolve to some other overload seem uncommon as they require a high amount of caller participation (passing arguments in the right nullable/numeric mix, all needing various conversions).
Subsequently we should be able to move from whole signature to per argument later in 7.0 or 8.0 without changing any but the most theoretic overload resolutions, strictly expanding the set of overloads that will resolve without error.
Additionally, if a user encounters an overload set with a high average arity - and where the caller arguments are (almost) all subject to conversions - they always have the option to do as many conversions by hand as necessary to disambiguate. For any other overload ambiguity issues a user might be able to use a parameter name difference to disambiguate (if any exists) but beyond that has no other options.
BC and risk wise this is a big difference, this PR can unblock the affected users and at the same time we don't realistically dig ourselves deeper into a BC hole.