Skip to content

Annotate more of the binder#40946

Merged
333fred merged 6 commits intodotnet:masterfrom
333fred:binder-annotations
Feb 6, 2020
Merged

Annotate more of the binder#40946
333fred merged 6 commits intodotnet:masterfrom
333fred:binder-annotations

Conversation

@333fred
Copy link
Copy Markdown
Member

@333fred 333fred commented Jan 14, 2020

No description provided.

@333fred 333fred added Area-Compilers Concept-Null Annotations The issue involves annotating an API for nullable reference types labels Jan 14, 2020
@333fred 333fred requested a review from a team January 14, 2020 02:13
Copy link
Copy Markdown
Member Author

@333fred 333fred Jan 14, 2020

Choose a reason for hiding this comment

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

This is what is forcing all the ImmutableArray<Location?> annotation changes. #ByDesign

Comment thread src/Compilers/CSharp/Portable/Binder/Binder_AnonymousTypes.cs Outdated
Comment thread src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs Outdated
Comment thread src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs Outdated
Comment thread src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs Outdated
Comment thread src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs Outdated
Copy link
Copy Markdown
Member

@jaredpar jaredpar left a comment

Choose a reason for hiding this comment

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

:shipit:

@333fred
Copy link
Copy Markdown
Member Author

333fred commented Jan 15, 2020

@dotnet/roslyn-compiler for a second review.

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

elementLocations [](start = 34, length = 16)

elementLocations [](start = 34, length = 16)

Should the type of elementLocations be adjusted in public API then, so we avoid the suppression? #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think so. If you're creating this from a public context, you should pass real locations as more of a matter of principle.


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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to clarify: When do we need to pass null locations internal?
Maybe we can mark as non-nullable across the board...


In reply to: 370338279 [](ancestors = 370338279,367179639)

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

ImmutableArray<Location?> elementLocations [](start = 12, length = 42)

what prompted that change?
Do we need a test for Compilation.CreateTupleTypeSymbol passing null locations? (I couldn't find one) #Closed

Copy link
Copy Markdown
Member Author

@333fred 333fred Jan 16, 2020

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

boundNamedArgumentsBuilder == null [](start = 28, length = 34)

consider changing this test to check boundNamedArgumentsSet instead, since the two locals are always initialized together (or not), then the suppression can be removed. #WontFix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Our approach for nullable has been to not change any semantic behavior, just to annotate what we are currently doing. I'm going to keep this going forward.


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

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

namedArgument.NameEquals [](start = 46, length = 24)

consider using an assertion instead #Closed

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

NameEquals [](start = 47, length = 10)

consider using an assertion here too (and at least one more place below) #Closed

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

name [](start = 38, length = 4)

consider asserting instead #Closed

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

results [](start = 53, length = 7)

why this suppression? #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

RemoveInvalidConstraints takes a non-null arraybuilder. We started with some nulls in the array, but just went through the whole thing to remove it.


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

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

Type [](start = 38, length = 4)

how do we know source.Type isn't null from surrounding code?
If we know because of some remote code, then assertion seems preferable.

Note: a few lines below we do a null-test on source.Type #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note: a few lines below we do a null-test on source.Type

BindToNaturalType should take care of that, but I'll add an assert.


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

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

ContainingType [](start = 43, length = 14)

Is the suppression okay because InFieldInitializer is true at this point? #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct.


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

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

destination [](start = 24, length = 11)

Should destination be declared as nullable? #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The only callers pass non-null.


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

Copy link
Copy Markdown
Member

@jcouv jcouv Jan 16, 2020

Choose a reason for hiding this comment

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

destination [](start = 103, length = 11)

Can't destination be null here? Seems dangerous #WontFix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The null check above is actually superfluous.


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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I'd missed your reply. Consider removing the superfluous null check so that we don't need those suppressions.
Suppressions are typically for when the compiler is not able to analyze properly, but here it's rather that the code is inconsistent (checks for null in one place, but would blow up with null in another).


In reply to: 370290111 [](ancestors = 370290111,367184489)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not going to change the semantics of the code in this PR.


In reply to: 375590101 [](ancestors = 375590101,370290111,367184489)

@jcouv
Copy link
Copy Markdown
Member

jcouv commented Jan 16, 2020

        CSharpAttributeData[] attributesBuilder,

Should this hold nullable elements instead? We test for null elements below #Closed


Refers to: src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs:56 in 55833bb. [](commit_id = 55833bb, deletion_comment = False)

@jcouv
Copy link
Copy Markdown
Member

jcouv commented Jan 16, 2020

            ConstantValue constantValue = node.ConstantValue;

Should this be nullable? we test for null below #Closed


Refers to: src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs:1043 in 69941f7. [](commit_id = 69941f757708eed5a20e8620b40e4a70e3ceaf0d, deletion_comment = False)

Copy link
Copy Markdown
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.

Done with review pass (iteration 3)

@jcouv jcouv self-assigned this Jan 16, 2020
@333fred
Copy link
Copy Markdown
Member Author

333fred commented Jan 23, 2020

Done with review pass (iteration 3)


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

Copy link
Copy Markdown
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.

Done with review pass (iteration 4). Still a question on CreateTuple API. Thanks

@jcouv jcouv added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Feb 3, 2020
@333fred 333fred force-pushed the binder-annotations branch from 7b46652 to 55833bb Compare February 6, 2020 00:46
@jcouv jcouv removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Feb 6, 2020
Copy link
Copy Markdown
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.

Done with review pass (iteration 5)

@333fred
Copy link
Copy Markdown
Member Author

333fred commented Feb 6, 2020

Verified this still builds locally.

@333fred 333fred merged commit 87551f4 into dotnet:master Feb 6, 2020
@333fred 333fred deleted the binder-annotations branch February 6, 2020 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Concept-Null Annotations The issue involves annotating an API for nullable reference types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants