Skip to content

Don't capture BoundNode when creating a LazyNoneOperation#36055

Merged
333fred merged 3 commits intodotnet:masterfrom
YairHalberstadt:CSharpOperationFactory-CreateInternal-Should-Not-Capture
Jun 3, 2019
Merged

Don't capture BoundNode when creating a LazyNoneOperation#36055
333fred merged 3 commits intodotnet:masterfrom
YairHalberstadt:CSharpOperationFactory-CreateInternal-Should-Not-Capture

Conversation

@YairHalberstadt
Copy link
Copy Markdown
Contributor

@YairHalberstadt YairHalberstadt commented May 30, 2019

Fixes #34918

@YairHalberstadt YairHalberstadt requested a review from a team as a code owner May 30, 2019 06:45
@YairHalberstadt
Copy link
Copy Markdown
Contributor Author

@333fred

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

Approve
Submit feedback approving these changes.


internal sealed class CSharpLazyNoneOperation : LazyNoneOperation
{
private readonly Func<BoundNode, ImmutableArray<IOperation>> _getChildren;
Copy link
Copy Markdown
Member

@333fred 333fred May 30, 2019

Choose a reason for hiding this comment

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

This is still capturing. We should instead hold onto the CSharpOperationFactory here, and call GetIOperationChildren off that instance below. #Closed

Friend NotInheritable Class VisualBasicLazyNoneOperation
Inherits LazyNoneOperation

Private ReadOnly _getChildren As Func(Of BoundNode, ImmutableArray(Of IOperation))
Copy link
Copy Markdown
Member

@333fred 333fred May 30, 2019

Choose a reason for hiding this comment

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

Same comment as C#. #Closed

Copy link
Copy Markdown
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

To actually address the bug, I'd like to totally remove the lambda allocation. Because it's still capturing the CSharpOperationFactory, the lambda isn't cached. We should just use the same pattern as the other nodes use and hold onto the CSharpOperationFactory manually. You'll have to change the accessibility of the GetIOperationChildren method, but we've already taken that pattern through the rest of the code and the factory/nodes are pretty strongly coupled already.

@333fred 333fred added Community The pull request was submitted by a contributor who is not a Microsoft employee. Feature - IOperation IOperation labels May 30, 2019
@YairHalberstadt
Copy link
Copy Markdown
Contributor Author

@333fred
The CSharpOperationFactory calls this with two different methods. It doesn't always use GetIOperationChildreb.

@333fred
Copy link
Copy Markdown
Member

333fred commented May 30, 2019

Then what we can do is have GetIOperationChildren check to see if the node passed in is a BoundMultipleLocalDeclarations, and have it do the correct thing in that case.

@YairHalberstadt
Copy link
Copy Markdown
Contributor Author

Done.

//TODO: Implement UsingLocalDeclaration operations correctly.
// For now we return an implicit operationNone, with a single child consisting of the using declaration parsed as if it were a standard variable declaration
// For now we return an implicit operationNone,
// and GetIoperationChildren will return a single child
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.

o [](start = 28, length = 1)

Nit: spelling

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.

Also trailing whitespace.


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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed, and fixed, assuming I got the right spelling mistake :-)

Copy link
Copy Markdown
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM other than the minor spelling and trailing whitespace issue. @dotnet/roslyn-compiler for a second review.

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

@333fred 333fred merged commit 09f3683 into dotnet:master Jun 3, 2019
@333fred
Copy link
Copy Markdown
Member

333fred commented Jun 3, 2019

Thanks @YairHalberstadt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. Feature - IOperation IOperation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSharpOperationFactory CreateInternal Should Not Capture

5 participants