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

Add IOperation support for ILocalFunctionStatement #20177

Merged
merged 3 commits into from
Jun 14, 2017

Conversation

mavasani
Copy link
Contributor

Fixes #19902

@mavasani
Copy link
Contributor Author

Tagging @dotnet/analyzer-ioperation @dotnet/roslyn-compiler for review

@mavasani mavasani changed the title Add support for ILocalFunctionStatement Add IOperation support for ILocalFunctionStatement Jun 12, 2017
private static ILocalFunctionStatement CreateBoundLocalFunctionStatementOperation(BoundLocalFunctionStatement boundLocalFunctionStatement)
{
IMethodSymbol localFunctionSymbol = boundLocalFunctionStatement.Symbol;
Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundLocalFunctionStatement.Body));
Copy link
Member

@333fred 333fred Jun 12, 2017

Choose a reason for hiding this comment

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

Can we assert that the body is in fact a block statement before the lazy, that way if it ever fails it'll fail in a helpful location with a better stack? #ByDesign

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we assert that the body is in fact a block statement before the lazy, that way if it ever fails it'll fail in a helpful location with a better stack?

It looks like Body is statically typed as BoundBlock.


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

@@ -0,0 +1,309 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Copy link
Member

@333fred 333fred Jun 12, 2017

Choose a reason for hiding this comment

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

Can you add some tests for invalid local function syntax? Such as int Local() => ; #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


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

/// </summary>
internal abstract partial class BaseLocalFunctionStatement : Operation, ILocalFunctionStatement
{
protected BaseLocalFunctionStatement(IMethodSymbol localFunctionSymbol, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
Copy link
Contributor

@AlekseyTs AlekseyTs Jun 13, 2017

Choose a reason for hiding this comment

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

ITypeSymbol type, Optional constantValue [](start = 115, length = 48)

Are these ever not null? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have used the common pattern already used in this generated file.


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

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 a note to #19720 (comment) to address this review comment.

public LazyLocalFunctionStatement(IMethodSymbol localFunctionSymbol, Lazy<IBlockStatement> body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue)
: base(localFunctionSymbol, isInvalid, syntax, type, constantValue)
{
_lazyBody = body ?? throw new System.ArgumentNullException("body");
Copy link
Contributor

@AlekseyTs AlekseyTs Jun 13, 2017

Choose a reason for hiding this comment

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

"body" [](start = 71, length = 6)

Use nameof? #Closed

Copy link
Contributor

@AlekseyTs AlekseyTs Jun 14, 2017

Choose a reason for hiding this comment

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

Use nameof?

It looks like there was no any response to this comment (#20177 (review)). #Closed

Copy link
Contributor Author

@mavasani mavasani Jun 14, 2017

Choose a reason for hiding this comment

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

I have used the existing pattern in this file. @heejaechang may want to address this in the generator. #Closed

Copy link
Contributor

@AlekseyTs AlekseyTs Jun 14, 2017

Choose a reason for hiding this comment

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

I am confused, are you actually running a generator, or adding this code manually. If the latter, please consider addressing provided feedback. For feedback you didn't addressed because of using existing pattern, pleas open issues to follow up (applies to other similar comments). #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't address feedback as this will eventually become a generated file. I can file issues so we can address them in the generator when it is eventually checked in. Does that seem fine?

Copy link
Contributor

@AlekseyTs AlekseyTs Jun 14, 2017

Choose a reason for hiding this comment

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

I can file issues so we can address them in the generator when it is eventually checked in. Does that seem fine?

Yes, as long as we have issues tracking the debt. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlekseyTs Added a note to #19720 (comment) to address this review comment.

bool isInvalid = boundLocalFunctionStatement.HasErrors;
SyntaxNode syntax = boundLocalFunctionStatement.Syntax;
ITypeSymbol type = null;
Optional<object> constantValue = default(Optional<object>);
Copy link
Contributor

@AlekseyTs AlekseyTs Jun 13, 2017

Choose a reason for hiding this comment

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

Optional constantValue = default(Optional); [](start = 12, length = 59)

This and the previous statement should be pushed into the constructor, I think. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have followed the general pattern used in this file. Heejae, you might want to take care of this when we checkin the generator.


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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlekseyTs Added a note to #19720 (comment) to address this review comment.

IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'x + Local2(p1)')
IBinaryOperatorExpression (BinaryOperationKind.IntegerAdd) (OperationKind.BinaryOperatorExpression, Type: System.Int32) (Syntax: 'x + Local2(p1)')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: IInvocationExpression (static System.Int32 Local2(System.Int32 p1)) (OperationKind.InvocationExpression, Type: System.Int32) (Syntax: 'Local2(p1)')
Copy link
Contributor

@AlekseyTs AlekseyTs Jun 13, 2017

Choose a reason for hiding this comment

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

static [](start = 38, length = 6)

interesting, display says the local function is static. @agocke is this intentional? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aleksey, this is due to the dumper printing out "static" when operation.Instance is null. See here: http://source.roslyn.io/#Roslyn.Test.Utilities/Compilation/OperationTreeVerifier.cs,539


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

Copy link
Contributor

@AlekseyTs AlekseyTs Jun 13, 2017

Choose a reason for hiding this comment

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

this is due to the dumper printing out "static" when operation.Instance is null.

We should fix that. The dumper should show what is there, not invent things to confuse people. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filed #20194

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jun 13, 2017

Done with review pass. #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jun 14, 2017

Done with review pass. #Closed

@mavasani
Copy link
Contributor Author

retest windows_debug_vs-integration_prtest please

@mavasani
Copy link
Contributor Author

retest windows_release_vs-integration_prtest please

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

@mavasani
Copy link
Contributor Author

Ignoring the vs integration test failures, these are still not up yet.

@mavasani
Copy link
Contributor Author

@jcouv @cston Can I get another review?

@mavasani mavasani merged commit 5492bf0 into dotnet:features/ioperation Jun 14, 2017
@mavasani mavasani deleted the ILocalFunctionStatement branch June 14, 2017 22:05
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.

5 participants