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

Learn from non-null test through suppression operator #32078

Merged
merged 3 commits into from
Jan 3, 2019

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Jan 1, 2019

Fixes #31733

@jcouv jcouv self-assigned this Jan 1, 2019
@jcouv jcouv requested a review from a team as a code owner January 1, 2019 17:07
slotBuilder.Free();
var slotBuilder = ArrayBuilder<int>.GetInstance();
GetSlotsToMarkAsNotNullable(receiverOpt, slotBuilder);
if (slotBuilder.Count > 0)
Copy link
Member

Choose a reason for hiding this comment

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

if (slotBuilder.Count > 0) [](start = 16, length = 26)

Consider removing the check since it looks unnecessary.

x!.F1(x); // 1
x.F1(x); // 2
x!.F1(x);
x.F1(x);
x.F1(x);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps remove the last x.F1(x); since it's now redundant.

{
void M(int? i)
{
i!!.Value.ToString();
Copy link
Contributor

Choose a reason for hiding this comment

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

!! [](start = 9, length = 2)

Is use of ! twice intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, to verify that we see through two layers

@AlekseyTs
Copy link
Contributor

Consider expanding testing to other scenarios that use GetSlotsToMarkAsNotNullable method.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 1)

@jcouv jcouv added this to the 16.0.P2 milestone Jan 2, 2019
@jaredpar
Copy link
Member

jaredpar commented Jan 2, 2019

approved

public string? field;
void M(C? c)
{
c?.field!.ToString();
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 This scenario makes me wonder if we should warn about unnecessary null-conditional dereference (you should remove the ?).

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #32105

@jcouv jcouv merged commit 7c1fe39 into dotnet:master Jan 3, 2019
@jcouv jcouv deleted the sticky-bang branch January 3, 2019 00:54
@jcouv jcouv mentioned this pull request Jan 3, 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.

4 participants