Skip to content
Discussion options

You must be logged in to vote

First, looking at the relevant section of the spec, I think the rules mean that both the source and target types of the chosen operator have to be "most specific". There isn't any rule that would favor one over the other. So I think the error is correct.

Second, that this code works at all is a deliberate spec violation. Conversion from S to T can be lifted to a conversion from S? to T?, but there is no rule to lift a conversion where one of the types is already nullable. The compiler contains a lengthy comment that explains that it does this incorrect lifting to be compatible with the old (C# 5.0) compiler.

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YairHalberstadt
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2004 on October 19, 2020 11:18.