Add IOperation support for ILocalFunctionStatement#20177
Add IOperation support for ILocalFunctionStatement#20177mavasani merged 3 commits intodotnet:features/ioperationfrom
Conversation
|
Tagging @dotnet/analyzer-ioperation @dotnet/roslyn-compiler for review |
| private static ILocalFunctionStatement CreateBoundLocalFunctionStatementOperation(BoundLocalFunctionStatement boundLocalFunctionStatement) | ||
| { | ||
| IMethodSymbol localFunctionSymbol = boundLocalFunctionStatement.Symbol; | ||
| Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundLocalFunctionStatement.Body)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
Can you add some tests for invalid local function syntax? Such as int Local() => ; #Resolved
There was a problem hiding this comment.
| /// </summary> | ||
| internal abstract partial class BaseLocalFunctionStatement : Operation, ILocalFunctionStatement | ||
| { | ||
| protected BaseLocalFunctionStatement(IMethodSymbol localFunctionSymbol, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : |
There was a problem hiding this comment.
ITypeSymbol type, Optional constantValue [](start = 115, length = 48)
Are these ever not null? #Closed
There was a problem hiding this comment.
I have used the common pattern already used in this generated file.
In reply to: 121588312 [](ancestors = 121588312)
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
"body" [](start = 71, length = 6)
Use nameof? #Closed
There was a problem hiding this comment.
Use nameof?
It looks like there was no any response to this comment (#20177 (review)). #Closed
There was a problem hiding this comment.
I have used the existing pattern in this file. @heejaechang may want to address this in the generator. #Closed
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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>); |
There was a problem hiding this comment.
Optional constantValue = default(Optional); [](start = 12, length = 59)
This and the previous statement should be pushed into the constructor, I think. #Closed
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
@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)') |
There was a problem hiding this comment.
static [](start = 38, length = 6)
interesting, display says the local function is static. @agocke is this intentional? #Closed
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
|
Done with review pass. #Closed |
|
Done with review pass. #Closed |
|
retest windows_debug_vs-integration_prtest please |
|
retest windows_release_vs-integration_prtest please |
…alFunctionStatement
|
Ignoring the vs integration test failures, these are still not up yet. |
Fixes #19902