-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Type inference should be able to infer U? for T when T? (and inference differs when a discard is used) #50782
Comments
Agree. Interested to see what the bug appears to be here, that's very strange. |
Hi, I will try to investigate the issue as an opportunity to get familiar with the platform. @RikkiGibson |
Hi! I made a little investigation of the issue. I managed to figure out why there is the different behaviour. See PR. During the investigation, I noticed an additional strange behaviour in several parts of the code. I think that this causes a warning in case of the discard delegate So, the first weird thing is during resolving actual type parameter here. This code is called every time when there are candidates for the type parameter. You can see, we ignore nullability information here whenever the conversions don't include nullability. This looks fine, but the conversions never includes nullability(I tried to debug the example. The first and the second phase of inferring contains conversions without nullability resolving in the type parameter never being The second weird thing is the type of parameter argument The third thing is ignoring |
Once runtime merges to a Roslyn toolset that has the fix for [issue 50782](dotnet/roslyn#50782) these annotations will be necessary. Front loading the work here with this change.
* Nullable annotation fixes Once runtime merges to a Roslyn toolset that has the fix for [issue 50782](dotnet/roslyn#50782) these annotations will be necessary. Front loading the work here with this change. * Apply suggestions from code review Co-authored-by: Stephen Toub <stoub@microsoft.com> --------- Co-authored-by: Stephen Toub <stoub@microsoft.com>
Version Used:
VisualStudio.16.Release/16.8.4+30907.101
C# Tools 3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd
Steps to Reproduce:
<LangVersion>9</LangVersion>
Expected Behavior:
T?
/[MaybeNull] T
can be matched bystring?
(in effect making itstring??
) without warnings. CurrentlyT
is always inferred to bestring
instead ofstring?
, resulting in warnings.Actual Behavior:
Warnings everywhere but on 1.
The text was updated successfully, but these errors were encountered: