Skip to content
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

Fix converted nullability on extract method #39134

Merged

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Oct 8, 2019

Fixes #39075

…t would cause incorrect behavior for casting of object to another type. Make sure to get type info of the cast expression, not the expression type
void M()
{
object? o = null;
var s = [|(string?)o|];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we also want a test for the explicit case where this cast is just (string)? It's invalid code but the compiler supposedly maintains the flow state and will consider s to still be string?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more tests. Please confirm they are the behavior we want :)

@ryzngard ryzngard merged commit ba47b2f into dotnet:master Oct 14, 2019
allisonchou added a commit to allisonchou/roslyn that referenced this pull request Nov 2, 2019
allisonchou added a commit to allisonchou/roslyn that referenced this pull request Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract method drops nullable annotation on explicit cast
2 participants