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

Handle tuple conversions and extension method this argument conversions in NullableWalker #29679

Merged
merged 3 commits into from
Sep 6, 2018

Conversation

cston
Copy link
Member

@cston cston commented Sep 5, 2018

No description provided.

@cston cston closed this Sep 6, 2018
@cston cston reopened this Sep 6, 2018
@cston
Copy link
Member Author

cston commented Sep 6, 2018

@dotnet/roslyn-compiler please review.

@@ -1457,6 +1457,7 @@ public Conversion ClassifyImplicitExtensionMethodThisArgConversion(BoundExpressi

if (sourceExpressionOpt?.Kind == BoundKind.TupleLiteral)
{
Debug.Assert(!IncludeNullability); // Top-level nullability is ignored.
Copy link
Contributor

@AlekseyTs AlekseyTs Sep 6, 2018

Choose a reason for hiding this comment

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

It is not clear why it top-level nullability should be ignored in this particular case. Could you please elaborate? Also, what about nested nullability? #Resolved

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 code path is not used when IncludeNullability is set. If it is in the future (when this assert fails), we'll need to update the delegate below.


In reply to: 215709176 [](ancestors = 215709176)

Copy link
Contributor

Choose a reason for hiding this comment

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

This code path is not used when IncludeNullability is set. If it is in the future (when this assert fails), we'll need to update the delegate below.

Consider capturing this in the comment instead. Something like: "At the moment this code path is taken only under this condition, if that changes, the code below will need an adjustment". And for other similar places.


In reply to: 215710774 [](ancestors = 215710774,215709176)

@@ -1858,6 +1864,7 @@ private Conversion ClassifyImplicitNullableConversion(TypeSymbol source, TypeSym

private Conversion GetImplicitTupleLiteralConversion(BoundTupleLiteral source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert(!IncludeNullability); // Top-level nullability is ignored.
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug.Assert(!IncludeNullability); // Top-level nullability is ignored. [](start = 12, length = 71)

I am not sure about the purpose of these asserts. Is it not valid to call this function when condition isn't met, something else?

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 method is not used with IncludeNullability currently, and the delegate below does not handle top-level nullability.


In reply to: 215710436 [](ancestors = 215710436)

@@ -32604,9 +32668,6 @@ static void F((B?, B) b)
}";
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
comp.VerifyDiagnostics(
// (12,21): warning CS8604: Possible null reference argument for parameter 'a' in 'A.implicit operator C(A a)'.
Copy link
Contributor

@AlekseyTs AlekseyTs Sep 6, 2018

Choose a reason for hiding this comment

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

// (12,21): warning CS8604: Possible null reference argument for parameter 'a' in 'A.implicit operator C(A a)'. [](start = 16, length = 111)

I think this warning was more informative than the one below. The remaining warning might be somewhat misleading. For example, what would we get for:

    static void F((B, B?) b)
    {
        (C, C?) c = b; // (ImplicitTuple)(ImplicitUserDefined)(ImplicitReference)
    }

Would it say: "Nullability of reference types in value of type '(B, B?)' doesn't match target type '(C, C?)'." ?

Consider opening an issue to follow-up #Pending

Copy link
Member Author

Choose a reason for hiding this comment

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

Logged #29699. Thanks.


In reply to: 215729273 [](ancestors = 215729273)

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 2)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks

@cston cston merged commit 99bda2c into dotnet:features/NullableReferenceTypes Sep 6, 2018
@cston cston deleted the tuples branch September 6, 2018 20:19
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.

3 participants