-
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
Local of unconstrained type parameter type is reported as NotAnnotated when using var #46236
Comments
follow-up: the "lie" only occurs for API like GetTypeInfo, which is intended to give you an rvalue type. The API in this issue description is GetDeclaredSymbol which is expected to provide the real annotation for the symbol. |
It might have been by design in C# 8, but with |
The initial state of parameters, though, is MaybeNull for both unconstrained |
I don't believe we're talking about parameters here. We're talking about |
Follow-up to offline discussion: this API is supposed to tell the truth 😉 so this is a bug. Thanks for helping me understand the scenario. I think that even if the API were supposed to give an annotation reflecting the "rvalue type", this would still be the wrong behavior--I must have just gotten mixed up when reviewing the description. |
Fixed and verified for 17.0 (p1 or p2) by #53691 |
Also backported fix to 16.11 |
The local returned from
SemanticModel.GetDeclaredSymbol()
fory1
hasType.NullableAnnotation == NullableAnnotation.NotAnnotated
, but should beNullableAnnotation.Annotated
instead.Compare with the
GetDeclaredSymbol()
result fory2
which hasType.NullableAnnotation == NullableAnnotation.Annotated
.The text was updated successfully, but these errors were encountered: